Created
December 2, 2015 06:18
-
-
Save whatalnk/58d3564ce2f27cf64f98 to your computer and use it in GitHub Desktop.
Codeforces #334 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 - 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 |
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 - 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Codeforces Round #334 Editorial - Codeforces