Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Codeforces #334 Div2
# [Problem - 604A - Codeforces](http://codeforces.com/problemset/problem/604/A)
xx = [500, 1000, 1500, 2000, 2500]
mm = gets.chomp.split(" ").map(&:to_f)
ww = gets.chomp.split(" ").map(&:to_f)
hs, hu = gets.chomp.split(" ").map(&:to_i)
calc_score = ->(x, m, w) {
(250 - m) * x / 250 - 50 * w
}
scores = Array.new
(0...5).each do |i|
scores << [0.3*xx[i], calc_score.call(xx[i], mm[i], ww[i])].max
end
puts (scores.inject(:+) + hs * 100 - hu * 50).to_i
# [Problem - 604B - Codeforces](http://codeforces.com/problemset/problem/604/B)
n, k = gets.chomp.split(" ").map(&:to_i)
ss = gets.chomp.split(" ").map(&:to_i)
if n.even? then
min_box = n / 2
d = (k - min_box) * 2
else
min_box = n / 2 + 1
d = (k - min_box) * 2 + 1
end
res = ss.pop(d)
half = ss.size / 2
right = ss.pop(half).reverse
ss.zip(right).each do |a, b|
res << a + b
end
puts res.max
@whatalnk

This comment has been minimized.

Copy link
Owner Author

whatalnk commented Dec 2, 2015

  • A
  • B
  • C
  • D
  • E
@whatalnk

This comment has been minimized.

Copy link
Owner Author

whatalnk commented Dec 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.