Created
February 4, 2018 12:27
-
-
Save whatalnk/e8c7108a277a76371ebbf7fb1e55c70b to your computer and use it in GitHub Desktop.
AtCoder APC #001 B
This file contains 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 = 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