Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created February 4, 2018 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/e8c7108a277a76371ebbf7fb1e55c70b to your computer and use it in GitHub Desktop.
Save whatalnk/e8c7108a277a76371ebbf7fb1e55c70b to your computer and use it in GitHub Desktop.
AtCoder APC #001 B
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
b = gets.chomp.split(" ").map(&:to_i)
sum_a = 0
sum_b = 0
cnt_a = 0
cnt_b = 0
n.times do |i|
if a[i] < b[i] then
cnt_a += ((b[i] - a[i]) / 2.0).ceil
else
cnt_b += (a[i] - b[i])
end
sum_a += a[i]
sum_b += b[i]
end
d = sum_b - sum_a
if d < 0 then
puts "No"
elsif cnt_a > d || cnt_b > d then
puts "No"
else
puts "Yes"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment