Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active December 28, 2015 01:01
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/da5b424c7ece59779b99 to your computer and use it in GitHub Desktop.
Save whatalnk/da5b424c7ece59779b99 to your computer and use it in GitHub Desktop.
Codeforces #337 Div2
# [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
# [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
@whatalnk
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment