Problem:


Score : 300 points

Problem Statement

A railroad running from west to east in Atcoder Kingdom is now complete.

There are N stations on the railroad, numbered 1 through N from west to east.

Tomorrow, the opening ceremony of the railroad will take place.

On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.

The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.

Here, it is guaranteed that F_i divides S_i.

That is, for each Time t satisfying S_i≤t and t％F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A％B denotes A modulo B, and there will be no other trains.

For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.

Constraints

1≤N≤500

1≤C_i≤100

1≤S_i≤10^5

1≤F_i≤10

S_i％F_i=0

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
C_1 S_1 F_1
:
C_{N-1} S_{N-1} F_{N-1}

Output

Print N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.

Sample Input 1

3
6 5 1
1 10 1

Sample Output 1

12
11
0

We will travel from Station 1 as follows:

5 seconds after the beginning: take the train to Station 2.

11 seconds: arrive at Station 2.

11 seconds: take the train to Station 3.

12 seconds: arrive at Station 3.

We will travel from Station 2 as follows:

10 seconds: take the train to Station 3.

11 seconds: arrive at Station 3.

Note that we should print 0 for Station 3.

Sample Input 2

4
12 24 6
52 16 4
99 2 2

Sample Output 2

187
167
101
0

Sample Input 3

4
12 13 1
44 17 17
66 4096 64

Sample Output 3

4162
4162
4162
0



Sample input:
3
6 5 1
1 10 1


Sample output:
12
11
0

Submission status: Wrong Answer

Solution code:
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
    ci, si, fi = map(int, input().split())
    c.append(ci)
    s.append(si)
    f.append(fi)


for i in range(n-1):
    ans = s[i]
    for j in range(i, n-1):
        if ans >= s[j]:
            ans += ans % f[j] + c[j]
        else:
            ans = s[j] + c[j]
    print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())
csf = [list(map(int, input().split())) for i in range(n-1)]

for i in range(n):
    now = 0
    for c,s,f in csf:
        s += ceil(max(0, now-s)//f)*f
        now = s+c
    print(now)
    csf = csf[1:]

Submission status: Wrong Answer

Solution code:
N = int(input())
lc=[]
ls=[]
lf=[]
for _ in range(N-1):
    C,S,F = map(int,input().split())
    lc.append(C)
    ls.append(S)
    lf.append(F)

for i in range(0,N-1):
    j = i
    ct = 0 #start time
    while j < N-1:
        if ct <= ls[j]:
            ct = ls[j] + lc[j]
            if j == N-2:print(ct)
        else:
            am = ct - ls[j]
            ct = ct + am % lf[j] + lc[j]
            if j == N-2:print(ct)
        j += 1
else:print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = []
for n in range(N-1):
  CSF.append([int(csf) for csf in input().split()])
print(CSF)

for i in range(N-1):
  total_time = 0
  for j in range(i, N-1):
    c12, s1, f1 = CSF[j]
    if s1 >= total_time:
      total_time = s1 + c12
    else:
      how_many_arrival_train = (total_time - s1) // f1
      how_long_waiting_time = (total_time - s1) % f1
      if how_long_waiting_time == 0:
        total_time = s1 + f1 * how_many_arrival_train + c12
      else:
        total_time = s1 + f1 * (how_many_arrival_train + 1) + c12
  print(total_time)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = list(list(map(int,input().split()))for i in range(N-1))

ans = [0]*N
for i in range(N-1):
    time = 0
    time += CSF[i][1]+CSF[i][0]
    for j in range(i+1,N-1):
        time = max(time,CSF[j][1])
        time += (time-CSF[j][1])%CSF[j][2]
        time += CSF[j][0]
    ans[i] = time
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())-1
csf=[list(map(int,input().split())) for i in range(n)]
# print(csf)
for i in range(n):
    time=0
    for j in range(i,n):
        if time<csf[j][1]:
            time=csf[j][1]+csf[j][0]
        else:
            time+=csf[j][2]-(time%csf[j][2])+csf[j][0]
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())-1
csf=[list(map(int,input().split())) for i in range(n)]
# print(csf)
for i in range(n):
    time=0
    for j in range(i,n):
        if time<csf[j][1]:
            time=csf[j][1]+csf[j][0]
        else:
            time+=time%csf[j][2]+csf[j][0]
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n):
        cur = 0
        for c, s, f in arr[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur += min(cur % f, f - cur % f) + c
        print(cur)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n):
        cur = 0
        for c, s, f in arr[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f ** 2 + c
        print(cur)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n - 1):
        cur = 0
        for j in range(i, n - 1):
            m, f, s = arr[j]  # move, first train, space (interval)
            if cur <= f:
                cur = f + m
            elif cur % s == 0:
                cur += m
            else:
                cur = cur + (cur % f) + m
        print(cur)
    print(0)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    arr = tuple(tuple(map(int, input().split())) for _ in range(n - 1))
    for i in range(n - 1):
        cur = 0
        for j in range(i, n - 1):
            m, f, s = arr[j]  # move, first train, space (interval)
            if cur <= f:
                cur = f + m
            elif cur % s == 0:
                cur += m
            else:
                cur = cur + f - (cur % f) + m
        print(cur)
    print(0)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [list(map(int, input().split())) for i in range(N-1)]
for i in range(N-1):
    t = 0
    for j in range(N-1):
        if t < L[j][1]:
            t = L[j][1]
        elif t % L[j][2] == 0:
            pass
        else:
            t = t + L[j][2] - t % L[j][2]
        t += L[j][0]  
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [list(map(int, input().split())) for i in range(N-1)] + [0, 0, 0]

for i in range(N-1):
    ans = L[i][1] + L[i][0]
    for j in range(i+1, N-1):
        if ans >= L[j][1]:
            ans += L[j][0]
        else:
            ans = L[j][1] + L[j][0]
    print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":
    N = int(input(""))
    for i in range(N-1):
        C,S,F = input().split()
        if i == 0:
            Clist = list([int(C)])
            Slist = list([int(S)])
            Flist = list([int(F)])  
        else:
            Clist.append(int(C))
            Slist.append(int(S))
            Flist.append(int(F))
    
    xlist = [0]*N
    for i in range(N-1):
        for j in range(i,N-1):
            if j == i:
                xlist[i] = xlist[i] + Slist[j]
            t = xlist[i]
            if Slist[j] > t:
                xlist[i] = Slist[j]

            if Slist[j] % Flist[j] != 0:
                xlist[i] = (int(xlist[i] / Flist[j]) + 1)*Flist[j]
            xlist[i] = xlist[i] + Clist[j]
            
    for i in range(N):
        print(xlist[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
csf=[]
for _ in range(n-1):
    csf.append(list(map(int,input().split())))
for i in range(n):
    t=0
    for j in range(i,n-1):
        if t<csf[j][1]:
            t += csf[j][1]
        elif t%csf[j][2]!=0:
            t = t+csf[j][2]-t%csf[j][2]
        t += csf[j][0]
    print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
c = [0]*n
s = [0]*n
f = [0]*n
ans = [0]*n

for i in range(n-1):
  c[i], s[i], f[i] = map(int, input().split())
    
for i in range(n):
  t = 0
  for j in range(i, n-1):
    if t <= s[j]:
      t = s[j]
    elif t % f[j] is 0:
      t = s[j] + f[j]
    else:
      t = t + f [j] - t % f [j];
    t += c[j];
  print(t)

Submission status: Wrong Answer

Solution code:
N=int(input())
CSF=[list(map(int,input().split())) for i in range(N-1)]
for i in range(N-1):
    ans=0
    for j in range(i,N-1):
        c,s,f=CSF[j]
        ans=max(s,ans+ans%-f)
        ans+=c
    print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
Lis=[list(map(int,input().split())) for i in range(N-1)]
Lis=Lis[::-1]
K=[0]
ans=[0]
for i in Lis:
    K.append(K[-1]+i[0])
    A=K[-1]+i[1]
    ans.append(ans[-1] if ans[-1] > A else A)
for i in ans[::-1]:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
ST = [[int(i) for i in input().split()] for j in range(N-1)]
for i in range(N-1):
    t = ST[i][1] + ST[i][0]
    for j in range(i+1,N-1):
        while (t-ST[j][1])%ST[j][2] != 0:
            t += 1
        else:
            t += ST[j][0]
    else:
        print(t)
print(0)

Submission status: Wrong Answer

Solution code:
l = input().split()
N = int(l[0])

C = []
S = []
F = []

for i in range(N - 1):
    l = input().split()
    C.append(int(l[0]))
    S.append(int(l[1]))
    F.append(int(l[2]))

# print(N, C, S, F)

for i in range(N - 1):
    spent = 0
    for j in range(i, N - 1):
        c = C[j]
        s = S[j]
        f = F[j]
        if spent < s:
            spent = s
        remain = (spent - s) % f
        if remain != 0:
            spent += remain
        spent += c
    print(spent)
print(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):

    CSF = list(zip(C,S,F))

    for i in range(N-1):
        t = 0
        for j in range(i,N-1):
            c,s,f = CSF[j]
            if t <= s:
                t = s + c
            else:
                t += (t-s) % f + c
        print(t)
    print(0)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]" 
    S = [int()] * (N-1)  # type: "List[int]" 
    F = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):

    CSF = list(zip(C,S,F))

    for i in range(N):
        t = 0
        for j in range(i,N-1):
            c,s,f = CSF[j]
            if t <= s:
                t = s + c
            else:
                t += (t-s) % f + c
        print(t)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]" 
    S = [int()] * (N-1)  # type: "List[int]" 
    F = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
para = [[i for i in map(int,input().split())] for i in range(N-1)]
dp = [0]*(N)

for i in range(N):
    for j in range(N-i-1):
        if dp[i] >= para[i+j][1] and dp[i]%para[i+j][2] == 0 :
            dp[i] += para[i+j][0]
        else : dp[i] = para[i+j][1] + para[i+j][0]
    print(dp[i])

Submission status: Wrong Answer

Solution code:
#入力例３みたいな時を考慮してなかった...
n = int(input())
csf = []
ans = [-1] * n

def st(S,pf,time): # time以下の数値のうち最小のs+t*n
    for i in range(10**10):
        if S + pf * (i-1) < time <= S + pf * i:
            return pf*i
            break

for i in range(n-1):
    csf.append(list(map(int,input().split())))

ans[n-1] = 0 
S = 10**10
csf = list(reversed(csf))
for i in range(n-1):
    c,s,f = csf[i][0],csf[i][1],csf[i][2]
    if i == 0:
        ans[n-2] = s + c
    else:
        if s+c <= S:
            ans[n-2-i] = ans[n-1-i]
        else:
            ans[n-2-i] = ans[n-1-i] + st(S,pf,c+s)
    S = s
    pf = f

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
#入力例３みたいな時を考慮してなかった...
n = int(input())
csf = []
ans = [-1] * n

def st(S,pf,time): # time以下の数値のうち最小のs+t*n
    for i in range(10**10):
        if S + pf * (i-1) < time <= S + pf * i:
            print(pf*i)
            return pf*i
            break

for i in range(n-1):
    csf.append(list(map(int,input().split())))

ans[n-1] = 0 
S = 10**10
csf = list(reversed(csf))
for i in range(n-1):
    c,s,f = csf[i][0],csf[i][1],csf[i][2]
    if i == 0:
        ans[n-2] = s + c
    else:
        if s+c <= S:
            ans[n-2-i] = ans[n-1-i]
        else:
            ans[n-2-i] = ans[n-1-i] + st(S,pf,c+s)
    S = s
    pf = f

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())

station = [list(map(int, input().split())) for i in range(N - 1)]



def next_start_time(arrive, C, S, F):
    for i in range(11000):
        if arrive <= S + i * F:
            break
    return S + (i * F) + C


for i in range(N - 1):
    ans = 0
    for j in range(i, N - 1):
        ans = next_start_time(ans, station[j][0], station[j][1], station[j][2])
    print(ans)

print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

station = [list(map(int, input().split())) for i in range(N - 1)]



def next_start_time(arrive, C, S, F):
    for i in range(110):
        if arrive <= S + i * F:
            break
    return S + (i * F) + C


for i in range(N - 1):
    ans = 0
    for j in range(i, N - 1):
        ans = next_start_time(ans, station[j][0], station[j][1], station[j][2])
    print(ans)

print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)

for n in range(N - 1):
    C[n], S[n], F[n] = map(int, input().split())

for t in range(0, N - 1):
    route_time = S[t]
    for i in range(t, N - 1):
        route_time = route_time + C[i]
        if i != N - 2:
            if route_time >= S[i + 1] and route_time % F[i + 1] == 0:
                continue
            elif route_time >= S[i + 1] and route_time % F[i + 1] != 0:
                route_time = (route_time // 17) * 17 + 17
            else:
                route_time = S[i + 1]
    print(route_time)
            
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)

for n in range(N - 1):
    C[n], S[n], F[n] = map(int, input().split())

for t in range(0, N - 1):
    route_time = S[t]
    for i in range(t, N - 1):
        route_time = route_time + C[i]
        if i != N - 2:
            if route_time >= S[i + 1] and route_time % F[i + 1] == 0:
                continue
            elif route_time >= S[i + 1] and route_time % F[i + 1] != 0:
                route_time = route_time // 17 + 17
            else:
                route_time = S[i + 1]
    print(route_time)
            
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)

for n in range(N - 1):
    C[n], S[n], F[n] = map(int, input().split())

for t in range(0, N - 1):
    route_time = S[t]
    for i in range(t, N - 1):
        route_time = route_time + C[i]
        if i != N - 2:
            if route_time >= S[i + 1] and route_time % F[i + 1] == 0:
                continue
            else:
                route_time = S[i + 1]
    print(route_time)
            
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

C = [0] * (N - 1)
S = [0] * (N - 1)
F = [0] * (N - 1)

for n in range(N - 1):
    C[n], S[n], F[n] = map(int, input().split())

for t in range(0, N - 1):
    route_time = S[t]
    for i in range(t, N - 1):
        route_time = route_time + C[i]
        if i != N - 2:
            if route_time >= S[i + 1]:
                continue
            else:
                route_time = S[i + 1]
    print(route_time)
            
print(0)

Submission status: Wrong Answer

Solution code:

memo = {}
hit = 0
def fast(i, t):
    global hit
    if i >= N-1:
        e = t
        return e
    if (i,t) in memo:
        e = memo[(i,t)]
        hit= hit+1
        return memo[(i,t)]

    c, s, f = CSF[i]
    if t < s: # はやくついた
        ts = s
    else:
        ts = (t//f)*f
    e = fast(i+1, ts+c)
    memo[(i,t)] = e
    return e

def solve(N, CSF):
    # S % F == 0
    result = [0]
    for i in range(N-2, -1, -1):
        e = fast(i, CSF[i][1])
        #print("i=%d"%i, e)
        result.append(e)
    
    for e in result[::-1]:
        print(e)
         
N = int(input())

CSF = []
for _ in range(N-1):
    CSF.append([int(x) for x in input().split()])

solve(N, CSF)
import sys
print(hit, file=sys.stderr)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[0]
T=[list(map(int,input().split())) for _ in range(n-1)][::-1]
t=0
for c,s,f in T:
    t+=c
    l.append(max(t+s,l[-1]))
for x in l[::-1]:
    print(x)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [list(map(int, input().split())) for _ in range(N - 1)]

ans = []
for i in range(N - 1):
    cnt = 0
    for j in range(i, N - 1):
        st = max(cnt, X[j][1])
        cnt = st + st % X[j][2] + X[j][0]
    ans.append(cnt)
ans.append(0)
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):

    def hasha(curr, ith):
        if curr > S[ith]:
            return S[ith] + F[ith]*(-(-(curr-S[ith])//F[ith]))
        else:
            return S[ith]

    ans = []
    for i in range(N-1):        # 開始駅
        buf = i
        for j in range(i, N-1):  # 現在駅
            buf = hasha(buf, j) + C[j]
        ans.append(buf)
    print(*ans, sep="\n")
    print("0")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]"
    S = [int()] * (N-1)  # type: "List[int]"
    F = [int()] * (N-1)  # type: "List[int]"
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):

    def hasha(curr, ith):
        if curr > S[ith]:
            return S[ith] + F[ith]*((curr-S[ith])//F[ith])
        else:
            return S[ith]

    ans = []
    for i in range(N-1):        # 開始駅
        buf = i
        for j in range(i, N-1):  # 現在駅
            buf = hasha(buf, j) + C[j]
        ans.append(buf)
    print(*ans, sep="\n")
    print("0")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N-1)  # type: "List[int]"
    S = [int()] * (N-1)  # type: "List[int]"
    F = [int()] * (N-1)  # type: "List[int]"
    for i in range(N-1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
CSF = [list(map(int,input().split())) for _ in range(N-1)]

ans = [0] * N
ans[N-2] = CSF[N-2][0] + CSF[N-2][1]
Sbn = CSF[N-2][1]
for i in reversed(range(N-2)):
    Sbn = max(Sbn, CSF[i][1])
    ans[i] = CSF[i][0] + CSF[i][1]
    if ans[i] < Sbn:
        ans[i] = ans[i+1]
    else:
        ans[i] += CSF[i+1][2]*math.ceil((ans[i]-CSF[i+1][1])/CSF[i+1][2]) -(ans[i]-CSF[i+1][1])  + (ans[i+1] - CSF[i+1][1])
        
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = [[int(i) for i in input().split()] for _ in range(N - 1)]

for i in range(N):
    t = 0
    for c, s, f in CSF[i:N - 1]:
        if t < s:
            t = s
        elif t % f != 0:
            t += t + f - t % f

        t += c
    print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
CSF = [list(map(int, input().split())) for i in range(n - 1)]
CSF.append([0, 0, 0])
for i in range(n):
    c, s, f = CSF[i]
    t = s + c
    for j in range(i + 1, n):
        c, s, f = CSF[j]
        if f == 0:
            break
        if t > s:
            s = s + (t - s - f + 1) // f * f
        t = s + c
    print(t)

Submission status: Wrong Answer

Solution code:
N = int(input())
time_table = []
time_table.append(0)
time = 0

train_list = []
for i in range (N-1):
    C, S, F = map(int,input().split())
    train_list.append([C, S, F])

for i in range (N):
    time = 0
    for j in range (i, N-1):
        C = train_list[j][0]
        S = train_list[j][1]
        F = train_list[j][2]

        if time<=S:
            time = S + C
        elif time % F ==0:
            time += C
        else:
            time = ((time - S)//F)*F + S + C

    print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
time_table = []
time_table.append(0)
time = 0

train_list = []
for i in range (N-1):
    C, S, F = map(int,input().split())
    train_list.append([C, S, F])

for i in range (N):
    time = 0
    for j in range (i, N-1):
        C = train_list[j][0]
        S = train_list[j][1]
        F = train_list[j][2]

        if time<=S:
            time = S + C
        else:
            time = ((time - S)//F)*F + S + C

    print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
time_table = []
time_table.append(0)
time = 0

for i in range (N-1):
    C, S, F = map(int,input().split())
    if time<=S:
        time = S + C
    else:
        time_temp = S
        while time != time_temp:
            time_temp +=F
        time = time_temp + C
    time_table.append(time)

for i in range (1, N+1):
    print(time_table[-i])

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = [0] + [list(map(int, input().split())) for _ in range(N-1)]

def start_from(i,t):
  if i==N:
    return t
  else:
    c,s,f = CSF[i]
    departure = max(s, ((((t-1)//f)+1)*f))
    return start_from(i+1, departure + c)
  
for i in range(1,N):
  print(start_from(i, i))
print(0)

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    trains = []
    for i in range(n-1):
        trains.append(f())

    for i in range(n):
        curpos = i
        time = 0
        for train in trains[i:]:
            start_time = (time//train[2] +  time%train[2])* train[2] if time > train[1] else train[1]
            time = start_time + train[0]

        print(time)

        

solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
temp = 0
stations = list()

for i in range(n-1):
    stations.append(list(map(int,input().split())))


for i in range(n-1):
    temp=0
    c,s,f = stations[i]
    if temp < s:
        temp = s
    temp = temp + c
    for j in range(i+1,n-1):
        c,s,f = stations[j]
        if temp < s:
            temp = s
        temp = temp + c
    print(temp)
        
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
c, s, f = [], [], []
for i in range(n-1):
  ci, si, fi = map(int, input().split())
  c.append(ci)
  s.append(si)
  f.append(fi)
  
for i in range(n-3, -1, -1):
  c[i] = c[i] + c[i+1]
  
ans = [0]
for i in range(n-2, -1, -1):
  ans.append(max(ans[-1], c[i] + s[i]))
  
for i in range(n-1, -1, -1):
  print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
c = [0]*N
s = [0]*N
f = [0]*N
for i in range(N-1):
    c[i], s[i], f[i] = map(int, input().split())
ans = s.copy()
for i in range(N-1):
    for j in range(i, N-1):
        if s[j] + c[i] > s[j+1]:
            ans[i] += c[j]
        else:
            ans[i] = s[j+1] + c[j+1]
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n-1):
  l1=list(map(int,input().split()))
  l.append(l1)
for i in range(n-1):
  t=0
  t+=l[i][1]+l[i][0]
  for j in range(i+1,n-1):
    if t<l[j][1]:
      t=l[j][1]
      t+=l[j][0]
    else:
      t+=l[j][2]-t%l[j][2]
      t+=l[j][0]
  print(t)
print(0)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    csf = []
    for _ in range(N - 1):
        C, S, F = map(int, input().split())
        csf.append((C, S, F))
    
    ans = []
    for i in range(N - 1):
        c, s, _  = csf[i]
        t = c + s
        for ii in range(i + 1, N - 1):
            nc, ns, nf = csf[ii]
            if t > ns:
                ns += ((t - ns) // nf) * nf
            t += nc + ns - t
        ans.append(t)
    ans.append(0)
    
    for t in ans:
        print(t)
    

main()

Submission status: Wrong Answer

Solution code:
N=int(input())

lc=[]
ls=[]
lf=[]

for i in range(N-1):
  C,S,F=map(int,input().split())
  lc.append(C)
  ls.append(S)
  lf.append(F)

if ''.join([str(x) for x in lc])=='61':
  exit()

for i in range(N-1):
  t=0
  for j in range(i,N-1):
    if t<ls[j]:
      t=ls[j]
      t+=lc[j]
    else:
      t+=(t-ls[j])%lf[j]+lc[j]
  print(t)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
C = [0] * (N-1)
S = [0] * (N-1)
F = [0] * (N-1)
for i in range(N-1):
    C[i], S[i], F[i] = map(int, input().split())
time = [0] * N
flag = [[0] * N for i in range(N)]

for i in range(N-1):
    for j in range(i, N-1):
        p = True
        for k in range(j):
            if flag[k][j-1] < S[j]:
                p = False
        if j == 0:
            time[i] += S[i]
        else:
            if flag[i][j-1] == 0:
                if p:
                    time[i] += S[j]
                else:
                    time[i] += F[j]
        if time[i] < S[j]:
            time[i] = S[j]
        time[i] += C[j]
        flag[i][j] = time[i]

for i in range(N):
    print(time[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = [list(map(int,input().split())) for _ in [0]*(N-1)]

ans = []
ans.append(0)
ans.append(CSF[-1][0]+CSF[-1][1])
s2 = CSF[-1][1]
for i,row in enumerate(CSF[-2::-1],2):
    c,s,f = row
    c2,_,f2 = CSF[1-i]
    if c+s <= s2:
        ans.append(ans[-1])
        s2 = ((s2-c)//f)*f
    else:
        ans.append(((c+s-1)//f2+1)*f2 - s2 + ans[-1])
        s2 = s
for out in ans[::-1]:
    print(out)

Submission status: Wrong Answer

Solution code:
from math import ceil
N = int(input())
T = [list(map(int, input().split())) for _ in range(N-1)]

for i in range(N-1):
    t = T[i][1] + T[i][0]
    for j in range(i+1, N-1):
        C = T[j][0]
        S = T[j][1]
        F = T[j][2]
        if t < S:
            t = S + C
        else:
            t = S + ceil((t-S)//F)*F + C
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
C = []
S = []
F = []
for i in range(n-1):
  c,s,f = map(int, input().split())
  C.append(c)
  S.append(s)
  F.append(f)
  
C.append(0)
S.append(0)
F.append(0)

ans = [0] * n
ans[n-2] = S[n-2] + C[n-2]
pos = n-3
while pos >= 0:
  if (S[pos] + C[pos] - S[pos+1]) >= 0 and S[pos] + C[pos] >= max(F[pos+1:]):
    if (S[pos] + C[pos] - S[pos+1]) % F[pos+1] == 0:
      ans[pos] = S[pos] + C[pos] - S[pos+1] + ans[pos+1]
    else:
      ans[pos] = math.ceil((S[pos] + C[pos] - S[pos+1]) / F[pos+1]) * F[pos+1] + S[pos+1] + ans[pos+1]  
  else:
    ans[pos] = ans[pos+1]
  pos -= 1
  
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
C = []
S = []
F = []
for i in range(n-1):
  c,s,f = map(int, input().split())
  C.append(c)
  S.append(s)
  F.append(f)
  
C.append(0)
S.append(0)
F.append(0)

ans = [0] * n
ans[n-2] = S[n-2] + C[n-2]
pos = n-3
while pos >= 0:
  if (S[pos] + C[pos] - S[pos+1]) >= 0 and S[pos] + C[pos] >= ans[pos+1]:
    if (S[pos] + C[pos] - S[pos+1]) % F[pos+1] == 0:
      ans[pos] = S[pos] + C[pos] - S[pos+1] + ans[pos+1]
    else:
      ans[pos] = math.ceil((S[pos] + C[pos] - S[pos+1]) / F[pos+1]) * F[pos+1] + S[pos+1] + ans[pos+1]  
  else:
    ans[pos] = ans[pos+1]
  pos -= 1
  
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[list(map(int,input().split())) for i in range(n-1)]

def func(lst,i):
    ans=lst[i][1]+lst[i][0]
    #print(ans)
    for j in range(i+1,n-1):
        if ans<lst[j][1]:
            ans=lst[j][1]
            if ans%lst[j][2]!=0:
                ans+=(ans%lst[j][2])
                ans+=lst[j][0]
            else:
                ans+=lst[j][0]
        else:
            if ans%lst[j][2]!=0:
                ans+=(ans%lst[j][2])
                ans+=lst[j][0]
            else:
                ans+=lst[j][0]
    return ans

for i in range(n-1):
    print(func(lst,i))
print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
C=[]
S=[]
F=[]

for i in range(N-1):
    a = input().split()
    C.append(int(a[0]))
    S.append(int(a[1]))
    F.append(int(a[2]))

Time_list=[]
for i in range(N-1):
    cnt=0
    for j in range(i,N-1):
        if cnt <= S[j]:
            cnt = S[j] + C[j]
        else:
            if (cnt - S[j]) % F[j] == 0:
                cnt += C[j]
            else:
                cnt = cnt + F[j] - (cnt % F[j])
    Time_list.append(cnt)

for i in Time_list:
    print(i)
print(0)