Last active
December 30, 2015 00:18
-
-
Save ssov/7748189 to your computer and use it in GitHub Desktop.
テストケース2で死亡
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n, d = gets.chomp.split(" ").map{|i| i.to_i} | |
values = [] | |
n.times{ values << gets.chomp.to_i } | |
combinations = values.combination(2).to_a.map{|i| i.inject(:+)} | |
d.times{ | |
i = gets.chomp.to_i | |
m = combinations.select{|j| (i-j) >= 0}.max | |
puts m.nil? ? 0 : m | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment