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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#https://atcoder.jp/contests/abc084/tasks/abc084_c

n=ii()
carr,sarr,farr=[],[],[]

for _ in range(n-1):
    c,s,f=mii()
    carr.append(c)
    sarr.append(s)
    farr.append(f)

ans = [0]*n

for start in range(n-1):
    for temp in range(start,n-1):
        if ans[start]<sarr[temp]:
            ans[start]=carr[temp]+sarr[temp]
        else:
            aa= (ans[start]%farr[temp])
            ans[start]+=aa+carr[temp]
print(*ans)

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] = list(map(int, input().split()))
time = [0]*(n)
for i in range(0,n-1):
    time[i] = time[i] + s[i] + c[i]
    for j in range(i+1,n-1):
        if time[i] <= s[j]:
            time[i] = time[i] + s[j]-time[i] + c[j]
            break
        else:
            if time[i]%f[j] != 0:
                time[i] = time[i] + (((time[i]//f[j])+1)*f[j] - time[i]) + c[j]
            else:
                time[i] = time[i] + c[j]
for i in range(n):
    print(time[i])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=[LI() for i in range(n)]
for i in range(n-1):
    pos=i
    time=lis[i][1]+lis[i][0]
    pos=i+1
    while pos<n-1:
        if time<lis[pos][1]:
            time=lis[pos][1]
        if time%lis[pos][2]!=0:
            time+=(n-time%lis[pos][2])
        time+=lis[pos][0]
        pos+=1
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
csf = [list(map(int, readline().split())) for _ in range(n - 1)]
for i, (c, s, _) in enumerate(csf):
    s += c
    for j, (cc, ss, ff) in enumerate(csf[i + 1:]):
        if s <= ss:
            s = ss
        else:
            s += (s - ss) % ff
        s += cc
    print(s)
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
sys.setrecursionlimit(10 ** 7)

n = int(readline())
csf = [list(map(int, readline().split())) for _ in range(n - 1)]
for i, (c, s, _) in enumerate(csf):
    s += c
    for j, (cc, ss, ff) in enumerate(csf[i + 1:]):
        if s <= ss:
            s = ss
        else:
            s += s % ff
        s += cc
    print(s)
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
sys.setrecursionlimit(10 ** 7)

n = int(readline())
csf = [list(map(int, readline().split())) for _ in range(n - 1)]
for i, (c, s, _) in enumerate(csf):
    s += c
    for j, (cc, ss, ff) in enumerate(csf[i + 1:]):
        if s <= ss:
            s = ss
        else:
            if j + i < n - 2:
                s += s % ff
        s += cc
    print(s)
print(0)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc084/tasks/abc084_c
n = int(input())

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


ans = []
for i in range(n - 1):
    _c, start, _ = trains[i]
    t = start + _c
    for j in range(i + 1, n - 1):
        c, s, f = trains[j]
        if t >= s:
            t += (t - s) % f + c
        else:
            t = s + c
    ans.append(t)
ans.append(0)
for a in ans:
    print(a)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc084/tasks/abc084_c
n = int(input())

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


ans = []
for i in range(n - 1):
    _c, start, _ = trains[i]
    t = start + _c
    for j in range(i + 1, n - 1):
        c, s, f = trains[j]
        if t >= s:
            t += (t % f) + c
        else:
            t = s + c
    ans.append(t)
ans.append(0)
for a in ans:
    print(a)

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, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time % f[j] == 0 and time >= s[j]:
            time += c[j]
        elif time % f[j] == 0:
            time = s[j]
        elif time >= s[j]:
            #while time < s[j]:
            time += f[j] - time % f[j]
            time += c[j]
        else:
            time += s[j] + c[j]
    print(time)
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)
#c, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time % f[j] == 0 and time >= s[j]:
            time += c[j]
        elif time % f[j] == 0:
            time = s[j]
        elif time >= s[j]:
            #while time < s[j]:
            time += f[j] - time % f[j]
            time += c[j]
        else:
            while time < s[j]:
                time += f[j] - time % f[j]
            time += c[j]
    print(time)
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)
#c, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time % f[j] == 0 and time >= s[j]:
            time += c[j]
        elif time % f[j] == 0:
            time = s[j]
        else:
            while time < s[j]:
                time += f[j] - time % f[j]
            time += c[j]
    print(time)
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)
#c, s, f
for i in range(n - 1):
    time = s[i] + c[i]
    for j in range(i + 1, n - 1):
        if time % f[j] == 0 and time >= s[j]:
            time += c[j]
        else:
            while s[j] > time:
                #time += 1
                time += f[j] - time % f[j]
            time += c[j]
    print(time)
print(0)

Submission status: Wrong Answer

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

for i in range(N-1):
    ans = 0
    ans += csf[i][1] + csf[i][0]
    for j in range(i+1, N-1):
        if ans >= csf[j][1]:
            ans += csf[j][2] - (ans % csf[j][2]) + csf[j][0]
        else:
            ans = csf[j][1] + csf[j][0]
    
    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 i in range(n-1):
    c[i],s[i],f[i]=map(int,input().split())
for i in range(n-1):
    t=s[i]+c[i]
    for j in range(i+1,n-1):
        if t>=s[j]:
            t+=f[j]-t%f[j]+c[j]
        else:
            t=s[j]+c[j]
    print(t)
print('0')

Submission status: Wrong Answer

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

for i in range(N-1):
    ans = 0
    ans += csf[i][1] + csf[i][0]
    for j in range(i+1, N-1):
        if ans >= csf[j][1]:
            ans += ans % csf[j][2] + csf[j][0]
        else:
            ans = csf[j][1] + csf[j][0]
    
    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 i in range(n-1):
    c[i],s[i],f[i]=map(int,input().split())
for i in range(n-1):
    t=s[i]+c[i]
    for j in range(i+1,n-1):
        if t>=s[j]:
            t+=t%f[j]+c[j]
        else:
            t=s[j]+c[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())
for i in range(n-1):
    t=s[i]+c[i]
    for j in range(i+1,n-1):
        if t>=s[j]:
            t+=t%f[j]+c[j]
        else:
            t+=s[j]-t+c[j]
    print(t)
print('0')

Submission status: Wrong Answer

Solution code:
from sys import stdin
N=list(map(int,stdin.readline().strip().split()))[0]
eki=[list(map(int,input().split())) for _ in range(N-1)]

for i in range(len(eki)):
    x = eki[i][1]+eki[i][0]
    for j in range(i+1,len(eki)):
        if eki[j][1] >x:x=eki[j][1]
        x+=eki[j][0]
    print(x)
print(0)

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

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
N = int(readline())
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, readline().split())
for i in range(N):
    time = 0
    for c, s, f in zip(C[i:N-1], S[i:N-1], F[i:N-1]):
        if time < s:
            time = s
        else:
            time += (time-s) % f
        time += c
    print(time)

Submission status: Wrong Answer

Solution code:
N=int(input())

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

for i in range(N):
    sec=0
    for j in range(i,N-1):
        c,s,f=csflist[j]
    if sec<s:
        sec=s
    elif sec%f>0:
        sec+=f-(sec%f)
    sec+=c
print(sec)

Submission status: Wrong Answer

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

# 時刻tに駅iにいる時、駅i+1に到着する時刻を返す
def next(i,t):
    if t<=lst[i][1]:
        return lst[i][0]+lst[i][1]
    elif t%lst[i][2]==0:
        return t+lst[i][0]
    else:
        return t+lst[i][0]-(t%lst[i][2])

for i in range(n-1):
    time = 0
    for j in range(i,n-1):
        time = next(j,time)
    print(time)
print(0)

Submission status: Wrong Answer

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

# 時刻tに駅iにいる時、駅i+1に到着する時刻を返す
def next(i,t):
    if t<lst[i][1]:
        return lst[i][0]+lst[i][1]
    elif t%lst[i][2]==0:
        return t+lst[i][0]
    else:
        return t+lst[i][2]-(t%lst[i][2])

for i in range(n-1):
    time = 0
    for j in range(i,n-1):
        time = next(j,time)
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
ma = lambda : map(int,input().split())
ni = lambda : int(input())
import math
ceil = math.ceil
n = ni()
csf = []
for i in range(n-1):
    csf.append(tuple(ma()))
for i in range(n-1):
    ans = csf[i][1] + csf[i][0]
    for j in range(i+1,n-1):
        if ans<=csf[j][1]:
            ans =csf[j][1]+csf[j][0]
        else:
            ans = math.ceil(ans/csf[j][2]) +csf[j][0]
    print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
import math

N= int(input())
train = [[int(i) for i in input().split()] for _ in range(N-1)]
time = sum(train[0][:2])
start_list = []
for C,S,F in train[1:]:
    start = math.floor(time/F)*F
    if start < S:
        start = S
    start_list.append(start)
    time = start + C
print(time)
for stime,(C,S,F) in zip(start_list, train[1:]):
    print(time-stime+S)
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
c_ls, s_ls, f_ls = [0] * n, [0] * n, [0] * n
for i in range(n-1):
    c,s,f = map(int,input().split())
    c_ls[i] = c
    s_ls[i] = s
    f_ls[i] = f
# sta_num + 1 駅までの時間を求める
def to_sta(time_used, sta_num):
    if time_used < s_ls[sta_num]:
        return s_ls[sta_num] + c_ls[sta_num]
    else:
        return time_used + c_ls[sta_num] + ((time_used - s_ls[sta_num]) % f_ls[sta_num])
for start in range(n):
    time_used = 0
    for nex in range(start, n-1):
        time_used = to_sta(time_used, nex)
    print(time_used)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

ans = []
for i in range(N-1):
    T = 0
    for j in range(i, N-1):
        if T <= A[j][1]:
            T += A[j][0] + A[j][1] - T
        elif (T-A[j][1])%A[j][2] == 0:
            T +=  A[j][0] 
        else:
            T += -(-(T-A[j][1])//A[j][2])*A[j][2]  + A[j][0] 
    print(T)
    
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

for i in range(N-1):
    ans = 0
    T = 0
    for j in range(i, N-1):
        if T <= A[j][1]:
            T += A[j][0] + A[j][1] - T
        else:
            T += (T-A[j][1])%A[j][2]  + A[j][0] 
    print(T)
        
print(0)

Submission status: Wrong Answer

Solution code:
#5
#入力
N=int(input())
X=[ list( map(int,input().split())) for i in range(N-1)]

#デバッグ関連
debug=0#0:本番,1:デバッグ

def pront(*n):
    if debug==1:
        print(n)

#処理
if N==1:
    print(0)
else:
    C=[X[i][0] for i in range(N-1)]
    S=[X[i][1] for i in range(N-1)]
    F=[X[i][2] for i in range(N-1)]
    
    C.append(0)
    S.append(0)
    F.append(1)
    ans=[]
    pront(C,S,F)
    for i in range(N):
        i=-i-1
        if i==-1:
            ans.append(0)
            pront("a")
        else:
            p=C[i]+S[i]
            if p<S[i+1]:
                ans.append(ans[-1])
                pront("b")
            else:
                r=p%F[i+1]
                if r==0:
                    pront(p,S[i+1],ans[-1])
                    ans.append(p-S[i+1]+ans[-1])
                    pront("c")
                else:
                    ans.append(p-S[i+1]++ans[-1]+(F[i+1]-r))
                    pront("d")
                    
                    
    for i in range(N):
        print(ans[-1-i])

Submission status: Wrong Answer

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

for i in range(N-1):
    duration, start, freq = data[i]
    total = start + duration
    for j in range(i+1, N-1):
        d, s, f = data[j]
        if total < s:
            total = s + d
        elif total % f == 0:
            total += d
        else:
            total = total // f + f + d
    print(total)
print(0)

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

Submission status: Wrong Answer

Solution code:
n = int(input())

C, S, F = [0] * n, [0] * n, [0] * n

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

C, S, F = [0] * n, [0] * n, [0] * n

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

C, S, F = [0] * n, [0] * n, [0] * n

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

C, S, F = [0] * n, [0] * n, [0] * n

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())

C, S, F = [0] * n, [0] * n, [0] * n

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

time = C[0] + S[0]
flag = False
for i in range(1, n):
    if time < S[i]:
        flag = True
    
    time = max(time, S[i]) + C[i]

if flag:
    for i in range(n - 1):
        print(time)
    time = 0
else:
    for i in range(1, n):
        print(time)
        time = time - (S[i - 1] + C[i - 1]) + S[i]

print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0 for _ in range(N)]
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if A[j] < s:
      A[j] = s + c
    else:
      d = - (s - A[j]) // f + 1
      A[j] = s + f * d + c
for i in range(N):
  print(A[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0 for _ in range(N)]
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if A[j] < s:
      A[j] = s + c
    else:
      d = - (s - A[j]) // f + 1
      A[j] = s + f * d + c
  print(A)
for i in range(N):
  print(A[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0 for _ in range(N)]
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if A[j] < s:
      A[j] = s + c
    else:
      d = - (s - A[j]) // f
      A[j] = s + f * d + c
for i in range(N):
  print(A[i])

Submission status: Wrong Answer

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

def tr(s,n):
    time = c[s-1][1] + c[s-1][0]
    for j in range(s,n-1):
        if (time <= c[j][1]):
            time = c[j][1]+c[j][0]
            break
        else:        
            a = (time - c[j][1]) // c[j][2]
            if ((time - c[j][1])%c[j][2] != 0):
                a = a+1
            time = c[j][1]+c[j][2]*(a)+c[j][0]
    return time

ans = []
for k in range(1,n):
    ans.append(tr(k,n))
ans.append(0)
print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
cfs = [list(map(int, readline().split())) for i in range(n - 1)]
for i in range(n - 1):
    cnt = cfs[i][1] + cfs[i][0]
    for j in range(i + 1, n - 1):
        if cnt < cfs[j][1]:
            cnt = cfs[j][1] + cfs[j][0]
        else:
            cnt += (cnt - cfs[j][1]) % cfs[j][2] + cfs[j][0]
    print(cnt)
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for i in range(n-1):
    t = 0
    for j in range(i, n-1):
        if i == j:
            t += CSF[j][0]
            t += CSF[j][1]
        else:
            if t < CSF[j][1]:
                t = CSF[j][1]
                t += CSF[j][0]
            else:
                t += CSF[j][0]
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------

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

Ans = []
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 += ans % f
        ans += c
    Ans.append(ans)

for ans in Ans:
    print(ans)

Submission status: Wrong Answer

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

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

print(0)

Submission status: Wrong Answer

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

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

print(0)

Submission status: Wrong Answer

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

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

print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
c = [0 for i in range(n-1)]
s = [0 for i in range(n-1)]
f = [0 for i in range(n-1)]
for i in range(n-1) :
  c[i],s[i],f[i] = map(int,input().split())
  
for i in range(0,n-1) :
  ans = 0
  for j in range(i,n-1) :
    if s[j] <= ans and ans%f[j] == 0 :
      ans += c[j]
    elif s[j] > ans :
      ans += c[j] + (s[j]-ans)
    elif ans%f[j] != 0 :
      ans += c[j] + ans - (ans//f[j]+1)*f[j]
  print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    time = [0]*N
    data = [list(map(int,input().split()))for _ in range(N-1)]
    for i in range(N-1):
        for j  in range(i,N-1):
            c,s,f = data[j]
            if time[i] > s:
                tmp = time[i]-s
                if tmp % f != 0:
                    tmp //= f
                    tmp += 1
                else:
                    tmp //= f
                time[i] = tmp*f+c
            else:
                time[i] = s+c
    for t in time:
        print(t)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    time = [0]*N
    data = [list(map(int,input().split()))for _ in range(N-1)]
    for i in range(N-1):
        for j  in range(i,N-1):
            c,s,f = data[j]
            if time[i] > s:
                tmp = time[i]-s
                if tmp % f != 0:
                    tmp = 1
                else:
                    tmp = 0
                time[i] += tmp*f+c
            else:
                time[i] = s+c
    for t in time:
        print(t)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
c=[0 for _ in range(n-1)]
s=c[:]
f=c[:]
for i in range(n-1):
  c[i],s[i],f[i]=map(int,input().split())
for i in range(n-1):
  t=0
  for j in range(i,n-1):
    cc,ss,ff=c[j],s[j],f[j]
    if t>=ss:
      t+=t%ff+cc
    else:
      t=ss+cc
      
  print(t)






print(0)

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]
for i in range(n-3,-1,-1):
    p=csf[i][0]+csf[i][1]
    if p<=csf[i+1][1]:
        ans[i]=ans[i+1]
    else: ans[i]=math.ceil(p/csf[i+1][2])*csf[i+1][2]+ans[i+1]-csf[i+1][1]

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

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):
    tmpl = l[i:]
    t = 0
    for x in tmpl:
        c,s,f = x[0],x[1],x[2]
        if t >= s:
            t = t + t%f
        else:
            t = s
        t += c
    print(t)

Submission status: Wrong Answer

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

for i,csf in enumerate(CSF):
    c,s,f=csf[0],csf[1],csf[2]
    ans=c+s
    for j in range(i+1,N-1):
        csf_=CSF[j]
        c_,s_,f_=csf_[0],csf_[1],csf_[2]
        if ans<s_:
            ans=s_
        elif ans%f_!=0:
            ans+=ans%f_
        ans+=c_
    print(ans)
print(0)

Submission status: Wrong Answer

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

for i,csf in enumerate(CSF):
    c,s,f=csf[0],csf[1],csf[2]
    ans=c+s
    for j in range(i+1,N-1):
        csf_=CSF[j]
        c_,s_,f_=csf_[0],csf_[1],csf_[2]
        if ans<s_:
            ans+=(s_-ans)
        if ans%f_!=0:
            ans+=(ans%f_)
        ans+=c_
    print(ans)
print(0)