Skip to content

Instantly share code, notes, and snippets.

@ssov
Last active December 30, 2015 00:18
Show Gist options
  • Save ssov/7748189 to your computer and use it in GitHub Desktop.
Save ssov/7748189 to your computer and use it in GitHub Desktop.
テストケース2で死亡
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