Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code festival 2018 qual B; B
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
You can’t perform that action at this time.