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())
CSF=[[0]]+[list(map(int, input().split())) for _ in range(N-1)]

for j in range(1,N):
    t=0
    for i in range(j,N):
        if t<CSF[i][1]:
            t=CSF[i][1]
        elif t%CSF[i][2]!=0:
            t=t+CSF[i][2]-(t+CSF[i][0])%CSF[i][2]
        t+=CSF[i][0]
    print(t)
print(0)

Submission status: Wrong Answer

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

for j in range(1,N):
    t=0
    for i in range(j,N):
        if t<CSF[i][1]:
            t=CSF[i][1]
        if t%CSF[i][2]!=0:
            t=t+CSF[i][2]-(t+CSF[i][0])%CSF[i][2]
        t+=CSF[i][0]
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 02:27:58 2018

@author: Yuki
"""

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

def train_time(start_time=0, data_list=[12, 24, 6]):
    if data_list[1] <= start_time:
        return start_time + (data_list[2] - start_time%data_list[2])%data_list[2] + data_list[0]
    else:
        return data_list[1] + data_list[0]

#N = 4
#data = [[12, 24, 6], [52, 16, 4], [99, 2, 2]]

res = []
for i in range(N-1):
    need_time = 0
    for ii in range(i, N-1):
        need_time = train_time(need_time, data[ii])
    res.append(need_time)

for i in range(N-1):
    print(res[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
for i in range(N-1):
    A=input()
    A=A.rstrip().split(" ")
    list1.append([int(A[0]),int(A[1]),int(A[2])])
#print(list1)

t=0
for k in range(N-1):
    for j in range(N-1-k):
        if t<list1[j+k][1]:
            t=list1[j+k][1]
        if (t-list1[j+k][1])%list1[j+k][2]==0:
            pass
        else:
            t+=(t-list1[j+k][1])%list1[j+k][2]
        t+=list1[j+k][0]
    print(t)
    t=0
print(0)

Submission status: Wrong Answer

Solution code:
# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0

N = int(input())
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0


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

for s in range(1, N+1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            # print("i =", i)
            # print("S[", i, "] =", S[i])
            if t < S[i]:
                t = S[i]
                t += C[i]
                break
            else:
                for j in range(F[i]):
                    if (t + j) % F[i] == 0:
                        t = t + j
                        # print("notta zikan =", t)
                        t += C[i]
                        # print("tuita zikan =", t)
                        break
    print(t)

Submission status: Wrong Answer

Solution code:
# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0

N = int(input())
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0


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

for s in range(1, N+1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            # print("i =", i)
            # print("S[", i, "] =", S[i])
            if t < S[i]:
                t = S[i]
                break
            else:
                for j in range(F[i]):
                    if (t + j) % F[i] == 0:
                        t = t + j
                        # print("notta zikan =", t)
                        t += C[i]
                        # print("tuita zikan =", t)
                        break
    print(t)

Submission status: Wrong Answer

Solution code:
# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0

N = int(input())
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0


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

for s in range(1, N+1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            # print("i =", i)
            for j in range(10):
                if t <= S[i] + j * F[i]:
                    t = S[i] + j * F[i]
                    # print("notta zikan =", t)
                    t += C[i]
                    # print("tuita zikan =", t)
                    break
    print(t)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
#    N1 = 3
#    CSF1 = [[6,5,1],
#                   [1,10,1],
#                   [0,0,1]]
#    
#    N2 = 4
#    CSF2 = [[12, 24, 6],
#                    [52, 16, 4],
#                    [99, 2, 2],
#                    [0,0,1]]
#    
#    N3 = 1
#    CSF3 = [[0,0,1]]
#    
#    N = N3
#    CSF = CSF3
    
    N = int(input())
    CSF = []
    for i in range(N-1):
        CSF.append(list(map(int, input().split())))
    
    CSF.append([0,0,1])
    
    ans = [0]*N
    
    for i in range(N-2,-1,-1):
        to_next = CSF[i][0] + CSF[i][1]
        
        if to_next <= CSF[i+1][1]:
            ans[i] = ans[i+1]
        else:
            if to_next%CSF[i+1][2] == 0:
                ans[i] = to_next + ans[i+1] - CSF[i+1][1]
            else:
                ans[i] = (to_next//CSF[i+1][2]+1) * CSF[i+1][2] + ans[i+1] - CSF[i+1][1]

    for a in ans:
        print(a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""


N = int(input())
import math

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

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

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

time = 0
print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
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):
    x = S[i] + C[i]
    for j in range(i + 1, N - 1):
        a = (x - S[j]) // F[j]
        a = max(a, 0)
        t = S[j] + a * F[j]
        x = t + C[j]
    print(x)
print(0)

Submission status: Wrong Answer

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

    for i in range(N-1):
        t = 0
        now = i
        while now != N-1:
            if t < S[now]:
                t = S[now]
            for dt in range(101):
                if (t+dt)%F[now]==0:
                    t += C[now]
                    now += 1
                    break
        print(t)
    print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        if t < l[j][1]:
            t = l[j][1] 
           
        elif 0 == (t%(l[j][2])): 
            pass
        
        else:
            t += -(t%(l[j][2])) + l[j][2] 
        
        t += l[j][0] 

    print(t)

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t.append(l[i][0]+l[i][1])
    for j in range(1, N-i-1):
        if t[i] < l[i+j][1]:
            t[i] = l[i+j][1] + l[i+j][0]
           
        elif t[i] == (t[i]%(l[i+j][2])): 
            t[i] += l[i+j][0]
        else:
            t[i] += -(t[i]%(l[i+j][2])) + l[i+j][2] + l[i+j][0] 

t.append(0)
for i in range(N):
    print(t[i])

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t.append(l[i][0]+l[i][1])
    for j in range(1, N-i-1):
        if t[i] <= l[i+j][1]:
            t[i] = l[i+j][1] + l[i+j][0]
           
        else: 
            t[i] += -(t[i]%(l[i+j][2])) + l[i+j][2] + l[i+j][0] 

t.append(0)
for i in range(N):
    print(t[i])

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t.append(l[i][0]+l[i][1])
    for j in range(1, N-i-1):
        if t[i] < l[i+j][1]:
            t[i] = l[i+j][1] + l[i+j][0]
           
        else: 
            t[i] += -(t[i]%(l[i+j][2])) + l[i+j][2] + l[i+j][0] 

t.append(0)
for i in range(N):
    print(t[i])

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t.append(l[i][0]+l[i][1])
    for j in range(1, N-i-1):
        if t[i] <= l[i+j][1]:
            t[i] = l[i+j][1] + l[i+j][0]
            
        else: 
            t[i] += t[i]%(l[i+j][2]) + l[i+j][0] 

t.append(0)
for i in range(N):
    print(t[i])

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t.append(l[i][0]+l[i][1])
    for j in range(1, N-i-1):
        if t[i] < l[i+j][1]:
            t[i] = l[i+j][1] + l[i+j][0]
            
        else: 
            t[i] += t[i]%(l[i+j][2]) + l[i+j][0] 

t.append(0)
for i in range(N):
    print(t[i])

Submission status: Wrong Answer

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

t = []
for i in range(N-1):
    t.append(l[i][0]+l[i][1])
    for j in range(1, N-i-1):
        if t[i] < l[i+j][1]:
            t[i] = l[i+j][1] + l[i+j][0]
            
        else: 
            t[i] += t[i]%(l[i+j][2]) + l[i+j][0] 
    
for i in range(N-1):
    print(t[i])
print(0)

Submission status: Wrong Answer

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

ans = [0] * n
ans[-2] = c[-1] + s[-1]

for i in range(n-2):
	if (((c[-(i + 2)] + s[-(i + 2)] + f[-(i + 1)] - 1) // f[-(i + 1)])) * f[-(i + 1)] > max(s) :
		ans[-(i + 3)] = ans[-(i + 2)] + (((c[-(i + 2)] + s[-(i + 2)] + f[-(i + 1)] - 1) // f[-(i + 1)])) * f[-(i + 1)] - s[-(i + 1)]
	else:
		ans[-(i + 3)] = ans[-(i + 2)]

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

Submission status: Wrong Answer

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

ans = [0] * n
ans[-2] = c[-1] + s[-1]

for i in range(n-2):
	ans[-(i + 3)] = ans[-(i + 2)] + (((c[-(i + 2)] + s[-(i + 2)] + f[-(i + 1)] - 1) // f[-(i + 1)])) * f[-(i + 1)] - s[-(i + 1)]

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

Submission status: Wrong Answer

Solution code:
n = int(input())

c, s, f = [], [], []
for i in range(int(n) - 1):
    tmp = input().split()
    tmp = [int(t) for t in tmp]
    c.append(tmp[0])
    s.append(tmp[1])
    f.append(tmp[2])

a = [None] * n
for i in reversed(range(int(n))):

    if i == n - 1:
        a[i] = 0
        continue

    ta = s[i] + c[i]
    if i == n - 2:
        a[i] = ta
        continue

    for j in range(i, n - 2):
        nn = j + 1
        if ta <= s[nn]:
            ta = a[nn]
        else:
            yo = ta % f[nn]
            add = 0 if yo == 0 else f[nn] - yo
            ta += add + c[nn]
    a[i] = ta


[print(aa) for aa in a]

Submission status: Wrong Answer

Solution code:
n = int(input('input N: '))

c, s, f = [], [], []
for i in range(int(n) - 1):
    tmp = input('input C, S, F: ').split()
    tmp = [int(t) for t in tmp]
    c.append(tmp[0])
    s.append(tmp[1])
    f.append(tmp[2])

a = [None] * n
for i in reversed(range(int(n))):

    if i == n - 1:
        a[i] = 0
        continue

    ta = s[i] + c[i]
    if i == n - 2:
        a[i] = ta
        continue

    for j in range(i, n - 2):
        nn = j + 1
        if ta <= s[nn]:
            ta = a[nn]
        else:
            yo = ta % f[nn]
            add = 0 if yo == 0 else f[nn] - yo
            ta += add + c[nn]
    a[i] = ta


[print(aa) for aa in a]

Submission status: Wrong Answer

Solution code:
n = int(input())

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


for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time

            if wait >= 0:
                time += wait + c
                break

            test = int((wait * -1) // f)
            s += int(f * test) + f

        num += 1

    print(time)


print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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


for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time

            if wait >= 0:
                time += wait + c
                break

            test = (wait * -1) / f
            s += int(f * test) + f

        num += 1

    print(time)


print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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


for i in range(n - 1):
    num = i
    time = 0

    while num < n - 1:
        c, s, f = _list[num]

        if num == i:
            time += s + c
            num += 1
            continue

        while True:
            wait = s - time

            if wait >= 0:
                time += wait + c
                break

            test = (wait * -1) / f
            s += int(f * test)

        num += 1

    print(time)


print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

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

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		n = S[j] - a if a <= S[j] else (a - S[j]) % F[j]
		n = F[j] - n if n != 0 else n
		# n = S[j] - a if a <= S[j] else a % F[j]
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

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

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		# n = S[j] - a if a <= S[j] else (a - S[j]) % F[j]
		n = S[j] - a if a <= S[j] else F[j] - (a % F[j])
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

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

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		n = S[j] - a if a <= S[j] else (a - S[j]) % F[j]
		# n = S[j] - a if a <= S[j] else a % F[j]
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
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)

results = []
for i in range(N):
    x = 0
    for n in range(i, N-1):
        if x < S[n]:
            x = S[n]
        if not x % F[n] == 0:
            x += x % F[n]
        x += C[n]
    results.append(x)

for result in results:
    print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

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

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		# n = S[j] - a if a < S[j] else (a - S[j]) % F[j]
		n = S[j] - a if a <= S[j] else a % F[j]
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
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)

results = []
for i in range(N):
    x = 0
    for n in range(i, N-1):
        if x < S[n]:
            x = S[n]
        x += C[n]
    results.append(x)

for result in results:
    print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

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

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		n = S[j] - a if a < S[j] else (a - S[j]) % F[j]
		# n = S[j] - a if a < S[j] else a % F[j]
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
lines = []

for i in range(N-1):
    lines.append(input())

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

for line in lines:
	c, s, f = line.split()
	C.append(int(c))
	S.append(int(s))
	F.append(int(f))

A = []

for i in range(N-1):
	a = C[i] + S[i]
	for j in range(i + 1, N - 1):
		# n = S[j] - a if a < S[j] else (a - S[j]) % F[j]
		n = S[j] - a if a < S[j] else a % F[j]
		a = a + C[j] + n
	A.append(a)

for a in A:
	print(a)
print(0)

Submission status: Wrong Answer

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

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):
    start = i
    temp = 0
    starttime = s[i]
    for j in range(start,n-1):
        if j == start:
            starttime += c[j]
        else:
            now = starttime
            if starttime <= s[j]:
                starttime += c[j]
            else:
                count = 1
                now_is = starttime
                starttime = ( (now_is - s[j] )// f[j] + 1) * f[j] + s[j]

    ans.append(starttime)
ans.append(0)
        
for _ in ans:
    print(_)

Submission status: Wrong Answer

Solution code:
#TLE
n = int(input())
c = []
s = []
f = []
ans = []

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):
    start = i
    temp = 0
    starttime = s[i]
    for j in range(start,n-1):
        if j == start:
            starttime += c[j]
        else:
            now = starttime
            if starttime <= s[j]:
                starttime += c[j]
            else:
                count = 1
                now_is = starttime
                starttime = ( now_is // f[j] ) * f[j]
                starttime += c[j]
    ans.append(starttime)
ans.append(0)
        
for _ in ans:
    print(_)

Submission status: Wrong Answer

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

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):
    start = i
    temp = 0
    starttime = s[i]
    for j in range(start,n-1):
        if j == start:
            starttime += c[j]
        else:
            now = starttime
            if starttime <= s[j]:
                starttime += c[j]
            else:
                count = 1
                now_is = s[j]
                while starttime > now_is:
                    now_is += f[j]
                starttime = now_is
                starttime += c[j]
    ans.append(starttime)
ans.append(0)
        
for _ in ans:
    print(_)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for i in range(N-1):
    C_i = CSF[i][0]
    S_i = CSF[i][1]
    t = S_i + C_i
    for j in range(i+1,N-1):
        C_j, S_j, F_j = CSF[j]
        if t > S_j:
            w = t%F_j
            if w == 0:
                t += C_j
            else:
                t += F_j - w
        else:
            t = S_j + C_j
    print(t)
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-1):
    T = S[i]
    for j in range(i, N-1):
        if S[j] > T:
            T = S[j]
        if T % F[j] == 0:
            T += C[j]
        else:
            T += C[j] + T%F[j]
    print(T)
print(0)

Submission status: Wrong Answer

Solution code:
n  = int(input())
a = []
for i in range(n-1):
    a.append([int(i) for i in input().split()])
a.append([0,0,1])
#print(a)

for i in range(n):
    time = a[i][0]+a[i][1]
    for j in range(i+1, n-i):
        if(time < a[j][1]):
            time = a[j][0]+a[j][1]
        else:
            while(True):
                if(time%a[j][2] == 0):
                    time += a[j][0]
                    break
                else:
                    time += 1
    print(time)

Submission status: Wrong Answer

Solution code:
N=int(input().strip())
C=[0,]
S=[0,]
F=[0,]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c);S.append(s);F.append(f)
dept=[0]*N
arrv=[0]*N
dept[N-1]=S[N-1]
arrv[N-1]=dept[N-1]+C[N-1]
for i in range(1,N-1)[::-1]:
    dept[i]=S[i]
    dtemp=dept[i]
    for j in range(i+1,N):
        atemp=max(dtemp+C[j-1],dept[j])
        rest=atemp%F[j]
        if rest==0:
            dtemp=atemp
        else:
            dtemp=atemp+F[j]-rest
    arrv[i] =atemp+C[N-1]
for i in range(1,N):
    print(arrv[i])
print('0')

Submission status: Wrong Answer

Solution code:
N=int(input().strip())
C=[0,]
S=[0,]
F=[0,]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c);S.append(s);F.append(f)
dept=[0]*N
arrv=[0]*N
dept[N-1]=S[N-1]
arrv[N-1]=dept[N-1]+C[N-1]
for i in range(1,N-1)[::-1]:
    dept[i]=S[i]
    dtemp=dept[i]
    for j in range(i+1,N):
        atemp=max(dtemp+C[j-1],dept[j])
        dtemp=atemp+F[j]-atemp%F[j]#jを出発する時刻 
    arrv[i] =atemp+C[N-1]
for i in range(1,N):
    print(arrv[i])
print('0')

Submission status: Wrong Answer

Solution code:
N=int(input().strip())
C=[0,]
S=[0,]
F=[0,]
for i in range(N-1):
    c,s,f=map(int,input().split())
    C.append(c);S.append(s);F.append(f)
dept=[0]*N
arrv=[0]*N
dept[N-1]=S[N-1]
arrv[N-1]=dept[N-1]+C[N-1]
for i in range(1,N-1)[::-1]:
    dept[i]=S[i]
    dtemp=dept[i]
    for j in range(i+1,N):
        atemp=max(dtemp+C[j-1],dept[j])
        dtemp=atemp+atemp%F[j]#jを出発する時刻 
    arrv[i] =atemp+C[N-1]
for i in range(1,N):
    print(arrv[i])
print('0')

Submission status: Wrong Answer

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

if n == 1:
    print(0)
    exit()

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

print(0)

Submission status: Wrong Answer

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

for i in range(n-1):
    time = data[i][1]
    for j in range(i, n-1):  # kenntou
        if time < data[j][1]:
            time = data[j][1]
        if time % data[j][2] != 0:
            time += time - (time % data[j][2])
        time += data[j][0]
    print(time)

print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N = int(input())

stations = [inpl() for _ in range(N-1)]

for i in range(N):
    now = 0
    for C, S, F in stations[i:]:
        if now <= S:
            now = S
        now += -(-(now - S)%F)*F + C
    print(now)

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)
    
C.append(0)
S.append(0)
F.append(0)

A = []
    
for i in range(N):
    cost = sum(C[N-i-1:]) + S[N-i-1]
    if len(A) == 0:
        A.append(cost)
    else:
        A.append(cost if cost>=A[i-1] else A[i-1])
    
for a in A[::-1]:
    print(a)

Submission status: Wrong Answer

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

for i in range(1,N):
    time = 0
    time += S[i]
    for j in range(i,N-1):
        time += C[j]
        if S[j+1]>=time:
            time=S[j+1]
        else:
             time += int((time-S[j+1])%F[j+1])
    time += C[N-1]
    print(time)

print(0)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
params = [[int(param) for param in input().split()] for _ in range(n-1)]


while params:

    c,s,f = params.pop(0)
    total = s + c

    for index,param in enumerate(params):
        c,s,f = param


        if (s > total):
            total = s + c
        else:
            if ((total-s) % f == 0):
                total += c
            else:
                total = math.ceil((total-s)/f)*f + c
    
    print(total)
        
print(0)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
params = [[int(param) for param in input().split()] for _ in range(n-1)]


while params:

    c,s,f = params.pop(0)
    total = s + c

    for index,param in enumerate(params):
        c,s,f = param


        if (s > total):
            total = s + c
        else:
            if ((total-s) % f == 0):
                total += c
            else:
                total = math.ceil((total-s)/f)*f
    
    print(total)
        
print(0)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
params = [[int(param) for param in input().split()] for _ in range(n-1)]


while params:

    c,s,f = params.pop(0)
    total = s + c

    for index,param in enumerate(params):
        c,s,f = param


        if (s > total):
            total = s + c
        else:
            if ((total-s) % f == 0):
                total += c
            else:
                total = (math.floor((total-s) / f) + 1) * f
    
    print(total)
        
print(0)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
params = [[int(param) for param in input().split()] for _ in range(n-1)]


while params:

    c,s,f = params.pop(0)
    total = s + c

    for index,param in enumerate(params):
        c,s,f = param

        if ((total-s) % f == 0):
            total += c
        elif (s >= total):
            total = s + c
        else:
            total += math.floor((total-s)/f)*f
    
    print(total)
        
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
dist=[]
start=[]
fqcy=[]
for i in range(0,n-1):
    c, s, f = (int(i) for i in input().split())
    dist.append(c)
    start.append(s)
    fqcy.append(f)

for j in range(0,n-1):
    tmp = dist[j] + start[j]
    for i in range(j+1,n-1):
        if (tmp - start[i])<0:
            tmp = start[i] + dist[i]
        else:
            tmp = tmp + (tmp - start[i])%fqcy[i] + dist[i]
    print(tmp)
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
cs = []
ss = []
fs = []
for i in range(n - 1):
    c, s, f = input().split()
    c = int(c)
    s = int(s)
    f = int(f)
    cs.append(c)
    ss.append(s)
    fs.append(f)
for i in range(n - 1):
    t = 0
    for j in range(i, n - 1):
        c, s, f = cs[j], ss[j], fs[j]
        if t < s:
            t = s + c
        elif t % f == 0:
            t += c
        else:
            t = f - t % f + c
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
def calc(array):
    now = 0
    for train in array:
        if train[1] > now:
            now = train[1] + train[0]
        else:
            tmp = train[1]
            while now < tmp:
                now += train[2]
            now += train[0]
    print(now)


def main():
    n = int(input())
    array = [[int(x) for x in input().split()] for x in range(n - 1)]
    array.append([0, 0, 0])

    for i in range(len(array)):
        calc(array[i:])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for k in range(N):
	t = 0
	for i in range(k,N-1):
		if t <= T[i][1]:
			t = T[i][0]+T[i][1]
		else:
			t += T[i][0]+min(0,T[i][2]-t%T[i][2])
	print(t)

Submission status: Wrong Answer

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

for k in range(N):
	t = 0
	for i in range(k,N-1):
		if t <= T[i][1]:
			t = T[i][0]+T[i][1]
		else:
			t += T[i][0]+min(0,T[i][2]-T[i][2]%t)
	print(t)