Last active
February 2, 2018 12:00
-
-
Save whatalnk/cf269314bc42c190b5540d05201a60ea to your computer and use it in GitHub Desktop.
AtCoder ABC #084 C. Special Trains
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
# 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