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 = [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 = [0] * n
for i in range(n - 1):
    for j in range(i, n - 1):
        if ans[i] < s[j]:
            ans[i] = s[j]
        else:
            ans[i] += ans[i] % f[j]
        ans[i] += c[j]

for i in range(n):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
T = [0]*n
c,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)

for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
n = int(input())
T = [0]*n
c,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)

for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
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)

def d(x,t): #駅x時間ｔで移動するのにかかる時間
	if S[x]>=t:
		return C[x]+S[x]-t
	else:
		if (t-S[x])%F[x]==0:
			return C[x]
		else:
			return C[x]+F[x]-(t-S[x])%F[x]

for i in range(n-1):
	x=i
	ans=0
	for j in range(x,n-1):
		ans+=d(x,ans)
		x=+1
	print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
T = [0]*n
c,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)

for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
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)

def d(x,t): #駅x時間ｔで移動するのにかかる時間
	if S[x]>=t:
		return C[x]+S[x]
	else:
		if (t-S[x])%F[x]==0:
			return C[x]
		else:
			return C[x]+F[x]-(t-S[x])%F[x]

for i in range(n-1):
	x=i
	ans=0
	for j in range(x,n-1):
		ans+=d(x,ans)
		x=+1
	print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
T = [0]*n
c,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)

for i in range(n-1):
	c[i],s[i],f[i] = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    inlis = list()
    for _ in range(n-1):
        c, s, f= map(int, input().split())
        inlis.append([c, s, f])

    anslis = []

    for j in range(n-1):
        tmp = 0
        for i in range(j,n-1):
            c, s, f= inlis[i][0], inlis[i][1], inlis[i][2]
            if tmp < s:
                tmp = s
            
            amari = tmp % f
            tmp += amari

            tmp += c
        anslis.append(tmp)
    anslis.append(0)
    
    for k in anslis:
        print(k)
    


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import math
import sys
sys.setrecursionlimit(10**6)
n = int(input())

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

for i in range(n-1):
    csf_tmp = csf[i:]

    c, s, f = csf_tmp[0]

    t = c+s
    for j in range(1, len(csf_tmp)):
        c, s, f = csf_tmp[j]

        if t <= s:
            t = s
        else:
            t += (t-s) % f
        # print(t)
        t += c
        # print(t)
    print(t)
print(0)

Submission status: Wrong Answer

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


def next_time(S, i, j):  # j 駅までに S 秒かかる。 j + 1 駅までの時間を return
    if i == j:
        return 0
    else:
        S = max(S, lis[j][1])
        re = ((S - 1) // F + 1) * F + lis[j][0]
        return re


for i in range(N):
    S = 0
    for j in range(i, N):  # i 駅から N 駅に移動していく
        S = next_time(S, i, j)
    print(S)

Submission status: Wrong Answer

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


def next_time(S, i, j):  # k 駅までに S 秒かかる。 k + 1 駅までの時間を return
    if i == j:
        return 0
    else:
        S = max(S, lis[j][1])
        re = ((S - 1) // F + 1) * F + lis[j][0]
        return re


for i in range(N):
    S = 0
    for j in range(i, N):  # i 駅から N 駅に移動していく
        S = next_time(S, i, j)
    print(S)

Submission status: Wrong Answer

Solution code:
n = int(input())
cs = []
ss = []
fs = []

for _ in range(n-1):
    c, s, f = map(int, input().split())
    cs.append(c)
    ss.append(s)
    fs.append(f)

for i in range(n):
    t = 0
    for j in range(i, n-1):
        if t < ss[j]:
            t = ss[j] + cs[j]
        elif t % fs[j] == 0:
            t += cs[j]
        else:
            t = t + t % fs[j] + cs[j]
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
cs = []
ss = []
fs = []

for _ in range(n-1):
    c, s, f = map(int, input().split())
    cs.append(c)
    ss.append(s)
    fs.append(f)

for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        if t < ss[j]:
            t = ss[j] + cs[j]
        elif t % fs[j] == 0:
            t += cs[j]
        else:
            t = t + t % fs[j] + cs[j]
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

x = []
for i in range(N - 1):
    c, s, f = map(int, input().split())
    x.append([c, s, f])

ans = []
for i in range(N - 1):
    t = x[i][0] + x[i][1]
    for j in range(i + 1, N - 1):
        t = max(t + t % x[j][2], x[j][1])
        t += x[j][0]
    ans.append(t)
ans.append(0)

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

Submission status: Wrong Answer

Solution code:
url = "https://atcoder.jp/contests/abc087/tasks/arc090_a"
import copy
def main():
    n = int(input())
    t = [list(map(int, input().split())) for _ in range(n-1)]
    for i in range(len(t)):
        time = 0
        for j in range(i, len(t)):
            st = t[j]
            if time <= st[1]:
                time = st[1]
            elif time % st[2] == 0:
                pass
            else:
                time += (time + st[2]) - (time % (st[2]))
            time += st[0]
        print(time)
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
url = "https://atcoder.jp/contests/abc087/tasks/arc090_a"
import copy
def main():
    n = int(input())
    t = [list(map(int, input().split())) for _ in range(n-1)]
    for i in range(len(t)):
        time = 0
        for j in range(i, len(t)):
            st = t[j]
            if time <= st[1]:
                time = st[1]
            elif st[1] < time <= st[1] + st[2]:
                time = st[1] + st[2]
            else:
                time += (time - st[1]) % (st[2])
            time += st[0]
        print(time)
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
url = "https://atcoder.jp/contests/abc087/tasks/arc090_a"
import copy
def main():
    n = int(input())
    t = [list(map(int, input().split())) for _ in range(n-1)]
    for i in range(len(t)):
        time = 0
        for j in range(i, len(t)):
            st = t[j]
            if time < st[1]:
                time = st[1]
            elif time < st[1] + st[2]:
                time = st[1] + st[2]
            else:
                time += (time - st[1]) % (st[2])
            time += st[0]
        print(time)
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
url = "https://atcoder.jp/contests/abc087/tasks/arc090_a"
import copy
def main():
    n = int(input())
    t = [list(map(int, input().split())) for _ in range(n-1)]
    for i in range(len(t)):
        time = 0
        for j in range(i, len(t)):
            st = t[j]
            if time < st[1]:
                time = st[1]
            elif time < st[1] + st[2]:
                time = st[1] + st[2]
            else:
                print((time - st[1]) % (st[2]))
                time += (time - st[1]) % (st[2])
            time += st[0]
        print(time)
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
url = "https://atcoder.jp/contests/abc087/tasks/arc090_a"
import copy
def main():
    n = int(input())
    t = [list(map(int, input().split())) for _ in range(n-1)]
    for i in range(len(t)):
        time = 0
        for j in range(i, len(t)):
            st = t[j]
            if time < st[1]:
                time = st[1]
            else:
                time += time % (st[2])
            time += st[0]
        print(time)
    print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
x=[list(map(int,input().split())) for i in range(n-1)]
for i in range(n):
    ans=0
    for j in range(n-1-i):
        if ans%x[i+j][2]==0:
            a=0
        else:
            a=x[j][2]-(ans%x[i+j][2])
        ans=(max(ans+a,x[i+j][1]))
        ans+=x[i+j][0]
    print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

n = int(input())
c = [0 for _ in range(n-1)]
s = [0 for _ in range(n-1)]
f = [0 for _ in range(n-1)]
for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split())

t = [[-1 for _ in range(n)] for _ in range(n-1)]

for i in range(n-1):
    t[i][i] = s[i]

for i in range(n-1):
    for j in range(i, n): 
        if i != j:
            t[i][j] = t[i][j-1]+c[j-1]
            if j == n-1:
                break
            if t[i][j]-t[j][j] <= 0:
                t[i][j] = t[j][j]
            else:
                t[i][j] = t[j][j] + (t[i][j]-t[j][j])//f[j] * f[j]


#print('t =', t)

# output 
for i in range(n-1):
    print(t[i][n-1])
print(0)

Submission status: Wrong Answer

Solution code:
A=[0];S,F=0,1
for c,s,f in [map(int,input().split())for _ in "_"*(int(input())-1)][::-1]:A.append(A[-1]-(-max(s+c-S,0)//F)*F if S>0 else s+c);S,F=max(s,S),f
for a in A[::-1]:print(a)

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):
    ans = 0
    for c, s, f in csf[i::]:
        if ans <= s:
            ans = s
        else:
            if ans % f == 0:
                pass
            else:
                ans += (ans // f) * f
        ans += c
    print(ans)

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):
    ans = 0
    if i == N - 1:
        print(0)
    else:
        for c, s, f in csf[i::]:
            if ans <= s:
                ans = s
            else:
                if ans % f == 0:
                    pass
                else:
                    ans += (ans // f + 1) * f
            ans += c
        print(ans)

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):
    ans = 0
    for c, s, f in csf[i::]:
        if ans <= s:
            ans = s
        else:
            if ans % f == 0:
                pass
            else:
                ans += (ans // f + 1) * f
        ans += c
    print(ans)

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):
    ans = 0
    for j in range(i, N-1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s
        else:
            if ans % f == 0:
                pass
            else:
                ans = (ans // f + 1) * f
        ans += c
    print(ans)

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):
    ans = 0
    for j in range(i, N - 1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s - ans + c
        else:
            while ans < s:
                s += f
            if ans >= s:
                ans += c
            else:
                ans += c + s
    print(ans)

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):
    ans = 0
    for j in range(i, N - 1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s - ans + c
        else:
            while ans < s:
                s += f
            ans += c + s
    print(ans)

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):
    ans = 0
    for j in range(i, N - 1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s - ans + c
        else:
            while ans < s:
                s += f
            ans += c
    print(ans)

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):
    ans = 0
    for j in range(i, N - 1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s - ans + c
        else:
            while ans < s:
                ans += f
            ans += c
    print(ans)

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):
    ans = 0
    for j in range(i, N-1):
        c, s, f = csf[j]
        if ans <= s:
            ans += s-ans+c
        else:
            while ans <= s:
                ans += f
            ans += c
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    n = ni()
    C = []
    S = []
    F = []
    for i in range(n - 1):
        c, s, f = nm()
        C.append(c)
        S.append(s)
        F.append(f)
    for i in range(n - 1):
        time = 0
        for j in range(i, n - 1):
            if time <= S[j]:
                time = S[j] + C[j]
            else:
                time = time + (time - S[j]) % F[j] + C[j]
        print(time)
    print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for _ in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for station in range(N):
    now = station
    time = 0

    while now < N-1:
        if time < S[now]:
            time = S[now] + C[now]
        else:
            tmp = time - S[now]
            wait_time = tmp % F[now]
            time += wait_time + C[now]

        now += 1

    print(time)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
cost = [0]*n
start = [0]*n
freaq = [0]*n
dp = [[0]*n for _ in range(n)]

for i in range(n-1):
    cost[i],start[i],freaq[i] = map(int,input().split())
    dp[i][i] = start[i]

freaq[n-1] = 1

t = 0

for i in range(n-1):
    for j in range(i+1):
        t = dp[j][i]
        t += cost[i]
        t += t%freaq[i+1]
        t = max(t,start[i+1])
        dp[j][i+1] = t

for i in range(n):
    print(dp[i][n-1])

Submission status: Wrong Answer

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

for i in range(N):
 p,q,r=C[i]
 A=q+p
 for j in range(i+1,N):
  c,s,f=C[j]
  m=(A-s)%f
  if A<s:A=s
  if m!=0:A+=f-m
  A+=c
 print(A)
print(0)

Submission status: Wrong Answer

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

for i in range(N-1):
    c,s,f=C[i]
    ans=s+c
    for j in range(i+1,N-1):
        nc,ns,nf=C[j]
        # print('D',ans,nc,ns,nf)
        ans=max(ans,ns)
        ans+=nc
    print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
def jikan(now_t,i):
    if i==n:
        return now_t
    else:
        if now_t<=s[i]:
            now_t = s[i]
        else:
            tmp1 = now_t//f[i]
            if now_t%f[i]!=0:
                now_t = (tmp1+1)*f[i]
        tmp = jikan(now_t+c[i],i+1)
        return tmp

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

Submission status: Wrong Answer

Solution code:
N = int(input())
Cls = [0]
Sls = [0]
Fls = [0]
lsans = []
for i in range(1,N):
    c,s,f = map(int,input().split())
    Cls.append(c)
    Sls.append(s)
    Fls.append(f)
for i in range(1,N):
    t = 0
    for j in range(i,N):
        if t < Sls[j]:
            t = Sls[j] + Cls[j]
        elif t%Fls[j] == 0:
            t += Cls[j]
        else:
            t += Fls[j]-(t%Fls[j])
    lsans.append(t)
lsans.append(0)
for i in lsans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
T = 0
t = 0
ans = []
for i in range(N-1):
    C, S, F = map(int, input().split())
    for j in range(len(ans)):
        if ans[j] <= S:
            ans[j] = S+C
        else:
            ans[j] = ans[j]+F-ans[j]%F+C
    ans.append(S+C)
for a in ans:
    print(a)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
T = 0
t = 0
ans = []
for i in range(N-1):
    C, S, F = map(int, input().split())
    for j in range(len(ans)):
        if ans[j] <= S:
            ans[j] = S+C
        else:
            ans[j] = S+(-(S-ans[j])//F)*F+C
    ans.append(S+C)
for a in ans:
    print(a)
print(0)

Submission status: Wrong Answer

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

ans = [0]
time_matrix = [[0] * n for i in range(n)]
for i in range(n):
    for j in range(i+1):
        if i < n-1:
            if time_matrix[i][j] % stations[i][2] == 0:
                waiting = 0
            else:
                waiting = stations[i][2] - (time_matrix[i][j] % stations[i][2])
            time_matrix[i+1][j] = max(time_matrix[i][j] + stations[i][0] + (time_matrix[i][j]%stations[i][2]), stations[i][0] + stations[i][1])

for i in range(n):
    print(time_matrix[n-1][i])

Submission status: Wrong Answer

Solution code:
def LIHW(h):
    return [list(map(int, input().split())) for _ in range(h)]


N = int(input())
X = LIHW(N-1)
ans = [0]*N

for i in range(N-1):
    time = [0]*N
    time[i] = X[i][1]+X[i][0]
    for j in range(i+1, N-1):
        if time[j-1] <= X[j][1]:
            time[j] = X[j][1]+X[j][0]
        else:
            time[j] = time[j-1] + (time[j-1]-X[j][1]) % X[j][2]+X[j][0]
    print(time[j])
print(0)

Submission status: Wrong Answer

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

for i in range(N-1):
    c1,s1,f1 = Plan[i]
    time = s1+c1
    for j in range(i+1,N-1):
        c,s,f = Plan[j]
        if time <= s:
            time = s
        elif (time-s)%f != 0:
            time = f-(time-s)%f
        time += c
    print(time)
print(0)

Submission status: Wrong Answer

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

for i in range(N-1):
    c1,s1,f1 = Plan[i]
    time = s1+c1
    for j in range(i+1,N-1):
        c,s,f = Plan[j]
        if s <= time:
            amari = (time-s)%f
            time += amari+c
        else:
            time = s+c
    print(time)
print(0)

Submission status: Wrong Answer

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

lst = []

for i in range(N - 1):
    c, s, f = station[i]

    for j in range(len(lst)):
        a = lst[j]

        if a >= s:
            a += (a % f) + c
        else:
            a = s + c

        lst[j] = a

    lst.append(s + c)


lst.append(0)
for a in lst:
    print(a)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
cL = []
sL = []
fL = []
for i in range(n - 1):
    c, s, f = map(int, input().split(" "))
    cL.append(c)
    sL.append(s)
    fL.append(f)

ans = 0
for i in range(n - 1):
    sm = 0
    for j in range(i, n - 1):
        c = cL[j]
        s = sL[j]
        f = fL[j]
        if sm < s:
            sm = s
        sm += c + (f - ((sm - s) % f) % f)
    print(sm)
print(0)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
cL = []
sL = []
fL = []
for i in range(n - 1):
    c, s, f = map(int, input().split(" "))
    cL.append(c)
    sL.append(s)
    fL.append(f)

ans = 0
for i in range(n - 1):
    sm = 0
    for j in range(i, n - 1):
        c = cL[j]
        s = sL[j]
        f = fL[j]
        if sm < s:
            sm = s
        sm += c + ((sm - s) % f)
    print(sm)
print(0)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
cL = []
sL = []
fL = []
for i in range(n - 1):
    c, s, f = map(int, input().split(" "))
    cL.append(c)
    sL.append(s)
    fL.append(f)

ans = 0
for i in range(n - 1):
    sm = 0
    for j in range(i, n - 1):
        c = cL[j]
        s = sL[j]
        f = fL[j]
        if sm < s:
            sm = s
        sm += c + (sm % f)
    print(sm)
print(0)

Submission status: Wrong Answer

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

arrive_time = [[] for _ in range(N-1)]
for start in range(N):
    ans = 0
    if start == N-1:
        print(ans)
        break
    for i in range(start, N-1):
        if ans <= S[i]:
            ans = S[i]
            ans += C[i]
        else:
            if ans % F[i] == 0:
                k = (ans - S[i]) // F[i]
            else:
                k = floor((ans - S[i]) / F[i])
            ans = S[i] + k * F[i]
            
            ans += C[i]
    print(ans)

Submission status: Wrong Answer

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

arrive_time = [[] for _ in range(N-1)]
for start in range(N):
    ans = 0
    if start == N-1:
        print(ans)
        break
    for i in range(start, N-1):
        if ans <= S[i]:
            ans = S[i]
            ans += C[i]
        else:
            k = floor((ans - S[i]) / F[i])
            ans = S[i] + k * F[i]
            
            ans += C[i]
    print(ans)

Submission status: Wrong Answer

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

arrive_time = [[] for _ in range(N-1)]
for start in range(N):
    ans = 0
    if start == N-1:
        print(ans)
        break
    for i in range(start, N-1):
        if ans <= S[i]:
            ans = S[i]
            ans += C[i]
        else:
            k = (ans - S[i]) // F[i]
            ans = S[i] + k * F[i]
            
            ans += C[i]
    print(ans)

Submission status: Wrong Answer

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

arrive_time = [[] for _ in range(N-1)]
for start in range(N):
    ans = 0
    if start == N-1:
        print(ans)
        break
    for i in range(start, N-1):
        if ans <= S[i]:
            ans = S[i]
            ans += C[i]
        else:
            add_time = ans % F[i]
            ans += add_time
            ans += C[i]
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input()) - 1
c = [0] * n
s = [0] * n
f = [0] * n
for i in range(n):
  c[i], s[i], f[i] = map(int, input().split())
  
for i in range(n):
  a = s[i] + c[i]
  for j in range(i + 1, n):
    a = max(a, s[j]) + c[j]
  print(a)
print(0)

Submission status: Wrong Answer

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

for i in range(N-1):
    ci,si,fi = li[i]
    time = si+ci
    for j in range(i+1,N-1):
        cj,sj,fj = li[j]
        time += time%fj
        if time < sj:
            time = sj
        time += cj
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
csf = [tuple(map(int, readline().split())) for _ in range(n-1)]

for i in range(n):
    now = 0
    for c, s, f in csf[i::]:
        if now <= s:
            now += s - now + c
        else:
            now += (now-s) % f + c
    print(now)

Submission status: Wrong Answer

Solution code:
# coding = SJIS

n = int(input())
sta = []
for i in range(n - 1):
    a, b, c = map(int, input().split())
    sta.append([a, b, c])
ans = []

for i in range(n - 1):
    time = 0
    for j in range(n - i - 1):
        if sta[i + j][1] > time:
            time = sta[i + j][1]
        if (time - sta[i + j][1]) % sta[i + j][2] != 0:
            time += (time - sta[i + j][1]) % sta[i + j][2]
        time += sta[i + j][0]
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
c=[]
sf=[]
for _ in range(n-1):
    ci,s,f=map(int,input().split())
    c.append(ci)
    sf.append([s,f])
for i in range(n):
    temp=0
    for j in range(i,n-1):
        if temp<=sf[j][0]:
            temp=sf[j][0]+c[j]
        else:
            temp=temp+temp%sf[j][1]+c[j]
    print(temp)

Submission status: Wrong Answer

Solution code:
import math
def lcm(x, y):
    '''x と y の最小公倍数を返す'''
    return (x * y) // math.gcd(x, y)

def main():
    n=int(input())
    csf=[list(map(int,input().split())) for _ in range(n-1)]
    for i in range(n):
        if i == n-1:
            print(0)
        else:
            t=0
            for c,s,f in csf[i:]:
                t = max(s,t)
                t = lcm(t,f)+c
                #print("start:",i, t)
            print(t)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    starts = [[int(item) for item in input().split()] for _ in range(N-1)]

    for i in range(N):
        temp_time = 0
        if i == N-1:
            print(0)
        else:
            for j in range(i,N-1):
                c, s, f = starts[j]
                if temp_time <= s:
                    temp_time = s

                if temp_time % f == 0:
                    pass
                else:
                    temp_time = (temp_time // f + 1) * temp_time
            
                temp_time += c
            print(temp_time)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

for i in range(n-1):
    c = route[i][0]+route[i][1]
    for j in range(i+1, n-1):
        if c < route[j][1]:
            c = route[j][0]+route[j][1]
        elif (c-route[j][1])%route[j][2] == 0:
            c += route[j][0]
        else:
            c += c-route[j][1]+(c-route[j][1])%route[j][2]
    ans.append(c)
ans.append(0)
for i in ans:
    print(i)

Submission status: Wrong Answer

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

for i in range(n-1):
    c = route[i][0]+route[i][1]
    for j in range(i+1, n-1):
        print(j)
        if c < route[j][1]:
            c = route[j][0]+route[j][1]
        elif (c-route[j][1])%route[j][2] == 0:
            c += route[j][0]
        else:
            c += c-route[j][1]+(c-route[j][1])%route[j][2]
    ans.append(c)
ans.append(0)
for i in ans:
    print(i)