Last active
December 28, 2015 01:01
-
-
Save whatalnk/da5b424c7ece59779b99 to your computer and use it in GitHub Desktop.
Codeforces #337 Div2
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
# [Problem - A - Codeforces](http://codeforces.com/contest/610/problem/A) | |
n = gets.chomp.to_i | |
if n.odd? then | |
puts 0 | |
else | |
ab = n / 2 | |
if ab.odd? then | |
puts (ab - 1) / 2 | |
else | |
puts ab / 2 - 1 | |
end | |
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
# [Problem - B - Codeforces](http://codeforces.com/contest/610/problem/B) | |
n = gets.chomp.to_i | |
jars = gets.chomp.split(" ").map(&:to_i) | |
jarmin = jars.min | |
if jars.uniq.length == 1 then | |
puts jars.length * jarmin | |
else | |
jars = jars * 2 | |
rem = 0 | |
i = 0 | |
while true | |
break if jars.empty? | |
j = jars.shift | |
if j == jarmin then | |
rem = [rem, i].max | |
i = 0 | |
else | |
i += 1 | |
end | |
end | |
puts n * jarmin + [rem, i].max | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Codeforces Round #337 (Div.2) Editorial - Codeforces