Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created February 5, 2017 04:02
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/970de9d0ebd4071e17ce36822f34b3eb to your computer and use it in GitHub Desktop.
Save whatalnk/970de9d0ebd4071e17ce36822f34b3eb to your computer and use it in GitHub Desktop.
AtCoder AGC #010 [Ruby]
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
# 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