Created
December 27, 2015 03:12
-
-
Save whatalnk/a17ad3ccfa9f2619b9f4 to your computer and use it in GitHub Desktop.
Codeforces #336 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 - A - Codeforces](http://codeforces.com/contest/608/problem/A) | |
n, s = gets.chomp.split(" ").map(&:to_i) | |
psgs = Array.new() | |
n.times do | |
psgs << gets.chomp.split(" ").map(&:to_i) | |
end | |
psgs = psgs.sort_by{|x| x[0]}.reverse | |
res = 0 | |
current = s | |
psgs.each do |f, t| | |
res += current - f | |
current = f | |
if res < t then | |
res = t | |
end | |
end | |
if current != 0 then | |
res += current | |
end | |
puts res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Codeforces Round #336 Editorial - Codeforces