Created
February 5, 2017 04:02
-
-
Save whatalnk/970de9d0ebd4071e17ce36822f34b3eb to your computer and use it in GitHub Desktop.
AtCoder AGC #010 [Ruby]
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 | |
even_ = 0 | |
odd_ = 0 | |
gets.chomp.split(" ").each do |x| | |
x = x.to_i | |
if x.even? then | |
even_ += 1 | |
else | |
odd_ += 1 | |
end | |
end | |
if odd_.odd? then | |
puts "NO" | |
else | |
puts "YES" | |
end |
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
# TLE | |
n = gets.chomp.to_i | |
aa = gets.chomp.split(" ").map(&:to_i) | |
while true | |
amax = aa.max | |
break if aa.any?{|x| x == 0} | |
imax = aa.index(amax) + 1 | |
s = (imax - 1) % n | |
n.times do |i| | |
j = (s + i + 1) % n | |
aa[j] -= (i + 1) | |
end | |
end | |
if aa.all?{|x| x == 0} then | |
puts "YES" | |
else | |
puts "NO" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment