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())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start < N-1:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        elif tmp < arr[start][1]+arr[start][2]:
            tmp = arr[start][2] + arr[start][1]
        else:
            tmp += (tmp-arr[start][1]) % arr[start][2]
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start < N-1:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        elif tmp+arr[start][1] < arr[start][2]:
            tmp += arr[start][2] - (tmp+arr[start][1])
        else:
            tmp += (tmp-arr[start][1]) % arr[start][2]
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start < N-1:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        elif tmp-arr[start][1] < arr[start][2]:
            tmp += arr[start][2] - (tmp-arr[start][1])
        else:
            tmp += (tmp-arr[start][1]) % arr[start][2]
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start < N-1:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        elif tmp-arr[start][1] < arr[start][2]:
            tmp += arr[start][2] - tmp-arr[start][1]
        else:
            tmp += (tmp-arr[start][1]) % arr[start][2]
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = []
for _ in range(N-1):
    arr.append(list(map(int, input().split())))
for i in range(N-1):
    start = i
    tmp = 0
    while start <= N-2:
        if tmp < arr[start][1]:
            tmp = arr[start][1]
        else:
            tmp += (tmp-arr[start][1]) % arr[start][2]
        tmp += arr[start][0]
        start += 1
    print(tmp)
print(0)

Submission status: Wrong Answer

Solution code:


if __name__ == '__main__':
    N=int(input())
    C=[]
    F=[]
    S=[]
    ans={i:0 for i in range(N)}
    for i in range(N-1):
        c,s,f=list(map(int,input().split()))
        C.append(c)
        S.append(s)
        F.append(f)

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

    for i in ans.values():
        print(i)

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 i in range(n-1):
    #i=0, 1つめの駅発を対象とする
    time = S[i] + C[i]
    for j in range(i+1, 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[j]
    print(time)
print(0)

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 i in range(n-1):
    #i=0, 1つめの駅発を対象とする
    time = S[i] + C[i]
    for j in range(i+1, 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)

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 i in range(n-1):
    #i=0, 1つめの駅発を対象とする
    time = S[i] + C[i]
    for j in range(i+1, n-1):
        if time <= S[j]:
            time = S[j] + C[j]
        else:
            time += (F[j] - time % F[j]) + C[j]
    print(time)
print(0)

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 i in range(n-1):
    #i=0, 1つめの駅発を対象とする
    time = S[i] + C[i]
    for j in range(i+1, n-1):
        if time <= S[j]:
            time = S[j] + C[j]
        else:
            time += time % F[j] + C[j]
    print(time)
print(0)

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 i in range(n-1):
    #i=0, 1つめの駅発を対象とする
    time = S[i] + C[i]
    for j in range(i+1, n-1):
        time += time % F[j] + C[j]
    print(time)
print(0)

Submission status: Wrong Answer

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

sum_val = 0
for i in range(N - 1):
    sum_val = StartTimeList[i] + TravelTimeList[i]
    for j in range(i + 1 , N - 1):
        sum_val = max(sum_val , StartTimeList[j])
        WaitTime = WaitTimeList[j] - (sum_val % WaitTimeList[j])
        sum_val += TravelTimeList[j] + WaitTime
    print(sum_val)
print("0")

Submission status: Wrong Answer

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

sum_val = 0
for i in range(N - 1):
    sum_val = StartTimeList[i] + TravelTimeList[i]
    for j in range(i + 1 , N - 1):
        sum_val = max(sum_val , StartTimeList[j])
        WaitTime = sum_val % WaitTimeList[j]
        sum_val += TravelTimeList[j] + WaitTime
    print(sum_val)
print("0")

Submission status: Wrong Answer

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

sum_val = 0
for i in range(N - 1):
    sum_val = StartTimeList[i] + TravelTimeList[i]
    for j in range(i + 1 , N - 1):
        if sum_val - StartTimeList[j] >= 0:
            WaitTime = (sum_val - StartTimeList[j]) % WaitTimeList[j]
        else:
            sum_val = StartTimeList[j]
            WaitTime = 0
        sum_val += TravelTimeList[j] + WaitTime
    print(sum_val)
print("0")

Submission status: Wrong Answer

Solution code:
N = int(input())

CSF = []
for i in range(N-1):
    tmp = list(map(int, input().split()))
    CSF.append(tmp)
    
for i in range(N-2):
    time = CSF[i][0] + CSF[i][1]
    #print("time1", time)
    for j in range(i+1, N-1):
        if time <= CSF[j][1]:
            time = CSF[j][1] + CSF[j][0]
        else:
            if time % CSF[j][2] == 0:
                time += CSF[j][0]
            else:
                time += (time - CSF[j][1]) % CSF[j][2] + CSF[j][0]
        #print("time", time)
    print(time)

print(CSF[N-2][0] + CSF[N-2][1])
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

CSF = []
for i in range(N-1):
    tmp = list(map(int, input().split()))
    CSF.append(tmp)
    
for i in range(N-2):
    time = CSF[i][0] + CSF[i][1]
    #print("time1", time)
    for j in range(i+1, N-1):
        if time <= CSF[j][1]:
            time = CSF[j][1] + CSF[j][0]
        else:
            time += CSF[j][0]
        #print("time", time)
    print(time)

print(CSF[N-2][0] + CSF[N-2][1])
print(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())

def calc(n):
    t=0
    for i in range(n,N-1):
        if(t<S[i]):
            t=S[i]
        t+=t%F[i]
        t+=C[i]
    print(t)


for i in range(N):
    calc(i)

Submission status: Wrong Answer

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

for i in range(N-1):
    time = L[i][1]
    for j in range(i, N-1):
        c, s, f = L[j]
        if time >= s:
            time += f - (time % f) 
        else:
            time += s - time
        time += c
    ans.append(time)

ans.append(0)
print(*ans, sep="\n")

Submission status: Wrong Answer

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

for i in range(N-1):
    time = L[i][1]
    for j in range(i, N-1):
        c, s, f = L[j]
        if time >= s:
            time += time % f 
        else:
            time += s - time
        time += c
    ans.append(time)

ans.append(0)
print(*ans, sep="\n")

Submission status: Wrong Answer

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

for i in range(N-1):
    time = L[i][1]
    for j in range(i, N-1):
        c, s, f = L[j]
        time += time % f if time >= s else s - time
        time += c
    ans.append(time)

ans.append(0)
print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N-1)]
for i in range(N-1):
    ans = 0
    for j in range(i, N-1):
        C, S, F = CSF[j]
        if ans <= S:
            ans = S
        else:
            diff = ans - S
            if diff % F != 0:
                ans += F - diff
        ans += C
    print(ans)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N-1)]
for i in range(N-1):
    ans = 0
    for j in range(i, N-1):
        C, S, F = CSF[j]
        if ans < S:
            ans = S
        else:
            diff = ans - S
            if diff % F != 0:
                ans += F - diff
        ans += C
    print(ans)
print(0)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    elif ans[j]%F != 0:
      ans[j] += ans[j]%F
    ans[j] += C
    
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    elif ans[j] > S:
      ans[j] += ans[j]%F
    ans[j] += C
    
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += S - ans[j]
    elif ans[j] > S:
      ans[j] += (ans[j]-S)%F
    ans[j] += C
    
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0 for i in range(N)]

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

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

sum_time=0
query = []
for i in range(N-1):
    query.append(many_int())

for i in range(N-1):
    C,S,F=query[i]
    sum_time = C+S

    for j in range(i+1,N-1):
        
        C, S, F =query[j]
        sum_time = max(S, sum_time)
        temp = int(sum_time-S)%(F)
        if temp!=0:
            sum_time += temp
        sum_time += C
    print(sum_time)
print(0)

Submission status: Wrong Answer

Solution code:
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

sum_time=0
query = []
for i in range(N-1):
    query.append(many_int())

for i in range(N-1):
    C,S,F=query[i]
    sum_time = C+S

    for j in range(i+1,N-1):
        
        C, S, F =query[j]
        sum_time = max(S, sum_time)
        temp = int(sum_time/(C+S))%(F)
        if temp!=0:
            sum_time += temp
        sum_time += C
    print(sum_time)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0 for i in range(N)]

for i in range(N-1):
  C, S, F = map(int, input().split())
  for j in range(0, i+1):
    if ans[j] < S:
      ans[j] += (S-ans[j])
    else:
      ans[j] += (ans[j]-S)//F%F
    ans[j] += C
    
    
for i in ans:
  print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = [0 for i in range(N)]

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

Submission status: Wrong Answer

Solution code:
import math
n = int(input())

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

for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        if i == j:
            time += (train_list[i][0] + train_list[i][1])
        else:
            if train_list[j][1] // time >= 1:
                time = train_list[j][1]
                time += train_list[j][0]
            else:
                p = math.ceil((time - train_list[j][1])//train_list[j][2])
                time = train_list[j][1] + train_list[j][2] * p
                time += train_list[j][0]
    print(time)

print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        if i == j:
            time += (train_list[i][0] + train_list[i][1])
        else:
            p = 0
            t = train_list[j][1] + train_list[j][2] * p
            if t // time >= 1:
                time = t
                time += train_list[j][0]
            else:
                p += ((time - t)//train_list[j][2])
                time = train_list[j][1] + train_list[j][2] * p
                time += train_list[j][0]
    print(time)

print(0)

Submission status: Wrong Answer

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


def time_calc(TC):
  pl = 0
  time = 0
  for info in TC:
    c, s, f = info
    if time < s:
      time = s
    if time % f != 0:
      time = (time // f) * (f + 1) 
    time += c
  return time
for i in range(n):
  print(time_calc(TC[i:]))

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
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
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    CSF=LLIN(N-1)
    def solve(CSF):
        now = 0
        for i,(c,s,f) in enumerate(CSF):
            if now <= s: #そのまま最速で乗れる
                now = s + c
                continue
            else:
                delay = now-s
                now == s + ceil(delay/f)
                now += c
        print(now)
    
    for i in range(N):
        solve(CSF[i:])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def getS(train):
  return train[0]
def getC(train):
  return train[1]

n = int(input())
trains = []
for x in range(n-1):
  trains.append([int(x) for x in input().split()])

ans = [0]
prevS = 0
prevC = 0
while trains:
  train = trains.pop()
  newS = getS(train)
  c = getS(train)
  s = getC(train)
  prevC += c
  if prevS > s + c:
    for x in range(len(trains)+1):
      ans.append(prevS + prevC - c)
    break
  else:
    ans.append(s + prevC)

  
  prevS = s


while ans:
  print(ans.pop())

Submission status: Wrong Answer

Solution code:
#84c
N = int(input())

#iの番号を合わせるのに、最初に不要だけど、値を入れておく。
C_list=[0]
S_list=[0]
F_list=[0]

for i in range(1,N):
    C,S,F = map(int, input().split())
    C_list.append(C)
    S_list.append(S)
    F_list.append(F)
    
#発車する時間は F*n + S

#指定した時間に到着したとき、次の駅への着時間を求める関数を拡張したら
#発駅と現在時刻からN駅への到着時間を求める再帰関数ができた。
def get_next_station_arrival_time(now_station_number,now_time):
    #終了条件
    if now_station_number == N:
        return now_time
    
    #継続時
    C = C_list[now_station_number]
    S = S_list[now_station_number]
    F = F_list[now_station_number]
    
    #次の発車時刻を求める … Fn+S >= now_time で最小となるnは?
    #ただし、始発前なら始発まで待機して出発
    if now_time <= S:
        return get_next_station_arrival_time(now_station_number + 1, S + C)
    else:
        n = (now_time - S)//F
        return get_next_station_arrival_time(now_station_number + 1, F*n + S + C)
    

for i in range(1,N+1):
     print(get_next_station_arrival_time(i,0))

Submission status: Wrong Answer

Solution code:
n = int(input())

l = [[int(i) for i in input().split(" ")] for _ in range(1, n)]


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

Submission status: Wrong Answer

Solution code:
n = int(input())

l = [[int(i) for i in input().split(" ")] for _ in range(1, n)]


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

Submission status: Wrong Answer

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

for i in range(n-1):
  syoki=hyou[i][0]+hyou[i][1]
  for j in range(i+1,n-1):
    temp=hyou[j][1]
    if  temp<syoki:
      temp+=math.floor((syoki-temp)/hyou[j][2])*hyou[j][2]
    syoki=temp+hyou[j][0]
  print(syoki)
print(0)

Submission status: Wrong Answer

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

for j in range(n):
  time = 0
  for i in range(j,n-1):
    if time > csf[i][1]:
      time += (time-csf[i][1])%csf[i][2]
    else:
      time = csf[i][1]

    time += csf[i][0]  
  print(time)

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
  csf = [int(x) for x in input().split()]
  c.append(csf[0])
  s.append(csf[1])
  f.append(csf[2])

for i in range(n-1):
  time = 0
  for j in range(i, n-1):
    if time<=s[j]:
      time=s[j]
    else:
      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):
  csf = [int(x) for x in input().split()]
  c.append(csf[0])
  s.append(csf[1])
  f.append(csf[2])

for i in range(n-1):
  time = 0
  for j in range(i, n-1):
    if time<s[j]:
      time=s[j]
    else:
      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):
  csf = [int(x) for x in input().split()]
  c.append(csf[0])
  s.append(csf[1])
  f.append(csf[2])

for i in range(n-1):
  time = 0
  for j in range(i, n-1):
    if time<s[j]:
      time=s[j]
    else:
      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):
  csf = [int(x) for x in input().split()]
  c.append(csf[0])
  s.append(csf[1])
  f.append(csf[2])

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

print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = []
for _ in range(N-1):
    c, s, f = map(int, input().split())
    X.append((c, s, f))
for k in range(N):
    t = 0
    for i in range(k, N-1):
        c, s, f = X[i]
        t += -(-t % f)
        t = max(t, s)
        t += c
    print(t)

Submission status: Wrong Answer

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

for index in range(N - 1):
    c, s, f = CSF[index]
    if now_time < s:
        now_time = s
    if now_time % f != 0:
        wait = f - (now_time % f)
        now_time += wait
    now_time += c
    min_el.append(c + s)
    if first:
        first = False
    else:
        sbn_list.append(-CSF[index - 1][0] - CSF[index - 1][1] + s)


print(now_time)
for i in range(N - 2):
    if sbn_list[i] > 0:
        print(max(min_el[i:]))
    else:
        now_time = max([now_time + sbn_list[i]] + min_el[i:])
        print(now_time)

print(0)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n):
    time = l[i][0] + l[i][1]

    for j in range(i + 1, n):
        if time <= l[j][1]:
            time = l[j][1]
        elif time % l[j][2] != 0:
            time += int(math.ceil(time / l[j][2]) * l[j][2])
        
        time += l[j][0]
    
    print(time)

print(0)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n):
    time = l[i][0] + l[i][1]
    for j in range(i + 1, n):
        
        if time <= l[j][1]:
            time = l[j][1]
        elif time % l[j][2] != 0:
            time += math.ceil((time - l[j][1]) / l[j][2]) * l[j][2]
        
        time += l[j][0]
    
    print(time)

print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
c,s,f = [],[],[]

for _ in range(N-1):
	c_tmp,s_tmp,f_tmp = map(int, input().split())
	c.append(c_tmp)
	s.append(s_tmp)
	f.append(f_tmp)

for i in range(N-1):
	ans = 0

	for j in range(i, N-1):
		if ans < s[j]:
			ans = s[j] + c[j]
			continue
		elif ans % f[j] == 0:
			ans += c[j]
		else:
			ans = ((ans//f[j])+1) + f[j] + c[j]

	print(ans)

print(0)

Submission status: Wrong Answer

Solution code:
import math

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)
	
S.append(0)
C.append(0)
F.append(1)
	
for i in range(N):
	time = S[i] + C[i] # 必ず始発に乗れる
	for j in range(i + 1, N):
		if time > S[j]:
			time = F[j] * (math.ceil(time // F[j])) # かかる待ち時間を足す
		else:
			time = S[j] # 開通まで待つ
		time += C[j] # 移動にかかる時間を足す
	print(time)

Submission status: Wrong Answer

Solution code:
import math

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)
	
S.append(0)
C.append(0)
F.append(1)
	
for i in range(N):
	time = S[i] + C[i] # 必ず始発に乗れる
	for j in range(i + 1, N):
		if time > S[j]:
			time = F[j] * (time // F[j]) # かかる待ち時間を足す
		else:
			time = S[j] # 開通まで待つ
		time += C[j] # 移動にかかる時間を足す
	print(time)

Submission status: Wrong Answer

Solution code:
import math

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)
	
S.append(0)
C.append(0)
F.append(0)
	
for i in range(N):
	time = S[i] + C[i] # 必ず始発に乗れる
	for j in range(i + 1, N):
		if time > S[j]:
			time += F[j] * (F[j] // time) # かかる待ち時間を足す
		else:
			time = S[j] # 開通まで待つ
		time += C[j] # 移動にかかる時間を足す
	print(time)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(n-1):
    l.append([int(i) for i in input().split()])
ans=[]
i=0 
while i<n-1:
    time=l[i][1]
    cost=0 
    j=i 
    while j<n-1: 
        start=time+ (time-l[j][1])%l[j][2] 
        time=start+l[j][0]
        j+=1 
    i+=1 
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
#input

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] = list(map(int, input().split()))

#引数　（始まりの駅, 現在の時間）
def calcTime(start, time):

    #着いていたら、現在の時間を返す
    if start == n - 1:
        return time
    #発車時刻より早くついてしまった場合は、発車時刻まで待つ
    if time < s[start]:
        time = s[start]
    #発車時刻より後でも、f[i]の倍数でないと電車が発車しないため、そこまで待つ
    time += f[start] - (time % f[start])
    #次の駅に着いた時間
    time += c[start]
    #次の駅に着いたので、次の駅の時間を求める。
    return calcTime(start + 1, time)
for i in range(n):
    print(calcTime(i, 0))

Submission status: Wrong Answer

Solution code:
#input

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] = list(map(int, input().split()))

#引数　（始まりの駅, 現在の時間）
def calcTime(start, time):
    #着いていたら、現在の時間を返す
    if start == n - 1:
        return time
    #発車時刻より早くついてしまった場合は、発車時刻まで待つ
    if time < s[start]:
        time = s[start]
    #発車時刻より後でも、f[i]の倍数でないと電車が発車しないため、そこまで待つ
    time += time % f[start]
    #次の駅に着いた時間
    time += c[start]
    #次の駅に着いたので、次の駅の時間を求める。
    return calcTime(start + 1, time)
for i in range(n):
    print(calcTime(i, 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):
  ans=0
  for c,s,f in CSF[i:]:
    if ans<s:
      ans=s
    elif ans%f!=0:
      ans+=f-ans%f+c
    ans+=c
  print(ans)

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

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

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

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