Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active February 2, 2018 12:00
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/cf269314bc42c190b5540d05201a60ea to your computer and use it in GitHub Desktop.
Save whatalnk/cf269314bc42c190b5540d05201a60ea to your computer and use it in GitHub Desktop.
AtCoder ABC #084 C. Special Trains
# ABC084
# C. Special Trains
n = gets.chomp.to_i
c = []
s = []
f = []
(n-1).times do
c_, s_, f_ = gets.chomp.split(" ").map(&:to_i)
c << c_
s << s_
f << f_
end
n.times do |i|
t = 0
(i...(n-1)).each do |j|
if t < s[j] then
t = s[j]
elsif t % f[j] == 0 then
else
t += (f[j] - t % f[j])
end
t += c[j]
end
puts t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment