Created
May 29, 2012 13:07
-
-
Save ninoseki/2828283 to your computer and use it in GitHub Desktop.
Codeforce121(Div2.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{|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