Skip to content

Instantly share code, notes, and snippets.

@ninoseki
Created May 29, 2012 13:07
Show Gist options
  • Save ninoseki/2828283 to your computer and use it in GitHub Desktop.
Save ninoseki/2828283 to your computer and use it in GitHub Desktop.
Codeforce121(Div2.B)
n = gets.chomp.to_i
a = gets.chomp.split(" ").map{|e| e.to_i}
days = 0
loop do
break if a[0] == 0 or a[-1] == 0
bang = false
for i in 1 .. (n - 2) do
bang = true if a[i] == 0 and a[i + 1] == 0
end
break if bang
days += 1
a.map!{|e|
e > 0 ? e -= 1 : e
}
end
puts days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment