Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created December 2, 2015 06:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save whatalnk/58d3564ce2f27cf64f98 to your computer and use it in GitHub Desktop.
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
Copy link
Author

whatalnk commented Dec 2, 2015

  • A
  • B
  • C
  • D
  • E

@whatalnk
Copy link
Author

whatalnk commented Dec 2, 2015

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