Created
October 15, 2018 12:34
-
-
Save whatalnk/2deefc7052d58ffab52ab2919a130fcc to your computer and use it in GitHub Desktop.
Code festival 2018 qual B; B
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
n, x = gets.chomp.split(" ").map(&:to_i) | |
ab = [] | |
ans = 0 | |
abmax = [0, 0] | |
n.times do | |
a, b = gets.chomp.split(" ").map(&:to_i) | |
ab << [a, b] | |
ans += a * b | |
if b > abmax[1] | |
abmax = [a, b] | |
elsif b == abmax[1] | |
if a > abmax[0] | |
abmax = [a, b] | |
end | |
end | |
end | |
puts ans - abmax[0] * abmax[1] + (abmax[0] + x) * abmax[1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment