Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created April 14, 2019 04:24
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/e7b915e6a3289369bc47f260de7e9ba1 to your computer and use it in GitHub Desktop.
Save whatalnk/e7b915e6a3289369bc47f260de7e9ba1 to your computer and use it in GitHub Desktop.
Codeforces #551 Div2 A - Serval and Bus
n, t = gets.chomp.split(" ").map(&:to_i)
ret = 10**5
ans = -1
n.times do |i|
s, d = gets.chomp.split(" ").map(&:to_i)
while true
if s >= t
st = s - t
if ret > st
ret = st
ans = i + 1
end
break
end
s += d
end
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment