Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created December 27, 2015 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/a17ad3ccfa9f2619b9f4 to your computer and use it in GitHub Desktop.
Save whatalnk/a17ad3ccfa9f2619b9f4 to your computer and use it in GitHub Desktop.
Codeforces #336 Div2
# [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
@whatalnk
Copy link
Author

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