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 = [list(map(int,input().split())) for i in range(N-1)]
CSF.append([0,0,1])
ans=[0]*N #
for i in range(N-1):
    for j in range(i,N-1):
        if j == i:
            ans[i]+=CSF[j][0]+CSF[j][1]
        else:
            if ans[i]<=CSF[j][1]:
                ans[i]=CSF[j][0]+CSF[j][1]
            else:
                ans[i]+=(CSF[j][2]-(ans[i]-CSF[j][1])%CSF[j][2])+CSF[j][0] 
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):
    for i in range(N-1): ##i駅からスタート
        t = 0
        for j in range(i,N-1):
            if t > S[j]:
                t = S[j]+(math.ceil((t-S[j])//F[j]))*F[j] + C[j]
            else:
                t = S[j] + C[j]
        print(t)
    print(0)
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

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

c.reverse()
s.reverse()
f.reverse()
t.reverse()
t_c.reverse()

ans = [0, t_c[0]]

for i in range(1, N-1):
    if t[i-1] > t[i] and t_c[i-1] > t_c[i]:
        calc = max(ans)
    else:
        calc = ans[i] + t_c[i] - s[i-1]
    ans.append(calc)

ans.reverse()
print(*ans, sep='\n')

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):
  t = S[i] + C[i]
  i += 1
  while i < N - 1:
    if t == S[i]:
      pass
    elif t > S[i]:
      if t - S[i] % F[i] == 0:
        pass
      else:
        t += F[i] * (t % F[i])
    else:
      t = S[i]
    t += C[i]
    i += 1
  print(t)
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):
  t = S[i] + C[i]
  i += 1
  while i < N - 1:
    if t >= S[i]:
      t += C[i]
    else:
      t = C[i] + S[i]      
    i += 1
  print(t)
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
C=list(list(map(int,input().split())) for i in range(n-1))
ans=0
for i in range(n-1):
    start=0
    for j in range(i,n-1):
        if i==j:
            start=C[i][0]+C[i][1]
            continue
        else:
            if start%C[j][2]==0 and start>=C[j][1]:
                start +=C[j][0]
            elif start<C[j][1]:
                start=C[j][0]+C[j][1]
            elif start%C[j][2]!=0:
                start +=((start//C[j][2])+1)*C[j][2]
                start +=C[j][0]
    print(start)
print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = [[int(x) for x in input().split()] for _ in range(n-1)]
for i in range(n-1):
    ans = 0
    ans += l[i][1] + l[i][0]
    for j in range(i+1, n-1):
        if ans % l[j][2] != 0:
            ans += l[j][2] - ans % l[j][2]
        ans += l[j][0]
    print(ans)
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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] = [int(_) for _ in input().split()]

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

Submission status: Wrong Answer

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

f = 0
station = 0
for i, (c, s, f) in enumerate(csf):
    t = s + c
    for j in range(i + 1, n - 1):
        C, S, F = csf[j][0], csf[j][1], csf[j][2]
        if t < S:
            t = S + C
        else:
            t += t % F + C
    print(t)
print(0)

Submission status: Wrong Answer

Solution code:

import sys
import itertools
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
c = [inputs() for _ in range(N-1)]
ans = [0]*(N)
start = [[0]*N for _ in range(N)]
for i in range(N-1):
    start[i][i] = c[i][1]
    for j in range(i,N-1):
        print(ans[i],i)
        if ans[i]<c[j][1]:
            start[i][j] = c[j][1]
            ans[i] = c[j][1]+c[j][0]
        else:
            ttim=0
            if ans[i]%c[j][2]!=0:
                ttim=c[j][2]-(ans[i])%c[j][2]
            start[i][j] = ttim+ans[i]
            ans[i] = ttim+ans[i]+c[j][0]
print(*ans)

Submission status: Wrong Answer

Solution code:

import sys
import itertools
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
c = [inputs() for _ in range(N-1)]
ans = [0]*(N)
start = [[0]*N for _ in range(N)]
for i in range(N-1):
    start[i][i] = c[i][1]
    for j in range(i,N-1):
        print(ans[i],i)
        if ans[i]<c[j][1]:
            start[i][j] = c[j][1]
            ans[i] = c[j][1]+c[j][0]
        else:
            ttim=0
            if ans[i]%c[j][2]!=0:
                ttim=c[j][2]-(ans[i])%c[j][2]
            start[i][j] = ttim+ans[i]
            ans[i] = ttim+ans[i]+c[j][0]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
c = [inputs() for _ in range(N-1)]
ans = [0]*(N)
ans[N-2]= c[N-2][0]+c[N-2][1]
maxs = c[N-2][1]
for i in range(N-3,-1,-1):
    if c[i][0]+c[i][1]<c[i+1][1] or c[i][0]+c[i][1]<maxs:
        ans[i]=ans[i+1]
    else:
        ttim=0
        if (c[i][0]+c[i][1])%c[i+1][2]!=0:
            ttim= c[i+1][2]-(c[i][0]+c[i][1])%c[i+1][2]
        ans[i]=c[i][0]+c[i][1]+ans[i+1]-c[i+1][1]+ttim
    maxs = max(maxs,c[i][1])
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
c = [inputs() for _ in range(N-1)]
ans = [0]*(N)
ans[N-2]= c[N-2][0]+c[N-2][1]
for i in range(N-3,-1,-1):
    if c[i][0]+c[i][1]<c[i+1][1] or ans[i+1]==ans[i+2]:
        ans[i]=ans[i+1]
    else:
        ttim=0
        if (c[i][0]+c[i][1])%c[i+1][2]!=0:
            ttim= c[i+1][2]-(c[i][0]+c[i][1])%c[i+1][2]
        ans[i]=c[i][0]+c[i][1]+ans[i+1]-c[i+1][1]+ttim
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
CSF=[]
for i in range(N-1):
    CSF.append(list(map(int,input().split())))
C=[]  #運行時間
S=[]  #スタート
F=[]  #周期
for i in range(N-1):
    C.append(CSF[i][0])
    S.append(CSF[i][1])
    F.append(CSF[i][2])

A=[0]*N

for i in range(N-1):
    A[i]=S[i]+C[i]
    for j in range(i+1,N-1):
        A[i]+=max(S[j]-A[i],0)
        M=(A[i]-S[j]+F[j])%F[j]
        A[i]+=C[j]+M

for i in A:
    print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[]
for i in range(n-1):
  c,s,f=map(int,input().split())
  lst.append([c,s,f])
for j in range(n-1):
  time=lst[j][0]+lst[j][1]
  ind=j
  for k in range(n-j-2):
    if time<=lst[ind+1][1] :
      time=lst[ind+1][0]+lst[ind+1][1]
      ind+=1
    elif (time-lst[ind+1][1])%lst[ind+1][2]==0:
      time=max(time,lst[ind+1][0]+lst[ind+1][1])+lst[ind+1][2]
      ind+=1
    else:
      time=max(time,lst[ind+1][0]+lst[ind+1][1])+lst[ind+1][2]+lst[ind+1][2]-(time-lst[ind+1][1])%lst[ind+1][2]
      ind+=1
  print(time)
print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
lst=[]
for i in range(n-1):
  c,s,f=map(int,input().split())
  lst.append([c,s,f])
for j in range(n-1):
  time=lst[j][0]+lst[j][1]
  ind=j
  for k in range(n-j-2):
    if time<=lst[ind+1][1] :
      time=lst[ind+1][0]+lst[ind+1][1]
      ind+=1
    elif (time-lst[ind+1][1])%lst[ind+1][2]==0:
      time+=lst[ind+1][2]
      ind+=1
    else:
      time+=lst[ind+1][2]+lst[ind+1][2]-(time-lst[ind+1][1])%lst[ind+1][2]
      ind+=1
  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.append(0)
s.append(0)
f.append(0)

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

    print(s_total)

Submission status: Wrong Answer

Solution code:

N = int(raw_input())
CSF = []
ans = []
for i in range(0,N-1):
  CSF.append(list(map(int,raw_input().split())))

for i in range(0,N):
  if i == N-1:
    break
  time = CSF[i][1] + CSF[i][0]
  for j in range(i,N-2):
    if time > CSF[j+1][1]:
      time = time + CSF[j+1][2] -((time - CSF[j+1][1])%CSF[j+1][2])
      #time = time + (max(time,CSF[j+1][2])- CSF[j+1][1])%min(time,CSF[j+1][2]) 
    elif time <= CSF[j+1][1]:
      time = CSF[j+1][1]
    time = time + CSF[j+1][0]
  ans.append(time)
ans.append(0)
for i in ans:
  print i

Submission status: Wrong Answer

Solution code:

N = int(raw_input())
CSF = []
ans = []
for i in range(0,N-1):
  CSF.append(list(map(int,raw_input().split())))

for i in range(1,N):
  if i == N-1:
    break
  time = CSF[i-1][1] + CSF[i-1][0]
  for j in range(i,N-1):
    if time >= CSF[j][1]:
      time = time + ((time - CSF[j][1])%CSF[j][2])
      #time = time + (max(time,CSF[j][2])- CSF[j][1])%min(time,CSF[j][2]) 
    elif time < CSF[j][1]:
      time = CSF[j][1]
    time = time + CSF[j][0]
  ans.append(time)
ans.append(CSF[N-2][0]+CSF[N-2][1])
ans.append(0)
for i in ans:
  print i

Submission status: Wrong Answer

Solution code:

N = int(raw_input())
CSF = []
ans = []
for i in range(0,N-1):
  CSF.append(list(map(int,raw_input().split())))

for i in range(1,N):
  if i == N-1:
    break
  time = CSF[i-1][1] + CSF[i-1][0]
  for j in range(i,N-1):
    if time >= CSF[j][1]:
      time = time + (max(time,CSF[j][2])- CSF[j][1])%min(time,CSF[j][2]) 
    elif time < CSF[j][1]:
      time = CSF[j][1]
    time = time + CSF[j][0]
  ans.append(time)
ans.append(CSF[N-2][0]+CSF[N-2][1])
ans.append(0)
for i in ans:
  print i

Submission status: Wrong Answer

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

for i in range(1,N):
  if i == N-1:
    break
  time = CSF[i-1][1] + CSF[i-1][0]
  for j in range(i,N-1):
    if time >= CSF[j][1]:
      time = time + max(time,CSF[j][2])%min(time,CSF[j][2]) - CSF[j][1]
    elif time < CSF[j][1]:
      time = CSF[j][1]
    time = time + CSF[j][0]
  ans.append(time)
ans.append(CSF[N-2][0]+CSF[N-2][1])
ans.append(0)
for i in ans:
  print i

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)

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

    print(s_total)

Submission status: Wrong Answer

Solution code:

N = int(raw_input())
CSF = []
ans = []
for i in range(0,N-1):
  CSF.append(list(map(int,raw_input().split())))

for i in range(1,N):
  if i == N-1:
    break
  time = CSF[i-1][1] + CSF[i-1][0]
  for j in range(i,N-1):
    if time >= CSF[j][1]:
      time = time + max(time,CSF[j][2])%min(time,CSF[j][2])
    elif time < CSF[j][1]:
      time = CSF[j][1]
    time = time + CSF[j][0]
  ans.append(time)
ans.append(CSF[N-2][0]+CSF[N-2][1])
ans.append(0)
for i in ans:
  print i

Submission status: Wrong Answer

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

for i in range(n-1):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        if res == 0:
            res += s + c
        else:
            res += max(s-res, (res+(f-1))//f - res) + c
    print(res)
else:
    print(0)

Submission status: Wrong Answer

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

for i in range(n-1):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        if res == 0:
            res += s + c
        else:
            res += max(s-res, res+(f-1)//f - res) + c
    print(res)
else:
    print(0)

Submission status: Wrong Answer

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

res = []
for i in range(0,n-1):
    c = csfs[i][0]
    s =csfs[i][1]
    f = csfs[i][2]
    syuppatu = s
    toutyaku = s+c
    for j in range(i+1,n-1):
        if toutyaku < csfs[j][1]:
            syuppatu = csfs[j][1]
            toutyaku = syuppatu+csfs[j][0]
        else:
            syuppatu = (toutyaku // csfs[j][2]) * csfs[j][2]
            toutyaku = syuppatu + csfs[j][0]
    res.append(toutyaku)
res.append(0)
for re in res:
    print(re)

Submission status: Wrong Answer

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

res = []
for i in range(0,n-1):
    c = csfs[i][0]
    s =csfs[i][1]
    f = csfs[i][2]
    syuppatu = s
    toutyaku = s+c
    for j in range(i+1,n-1):
        if toutyaku < csfs[j][1]:
            syuppatu = csfs[j][1]
            toutyaku = syuppatu+csfs[j][0]
        else:
            syuppatu = ((toutyaku + f-1) // f) * f
            toutyaku = syuppatu + csfs[j][0]
    res.append(toutyaku)
res.append(0)
for re in res:
    print(re)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

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

def f(i):
    ans_r = [0]
    cur = 0
    for c, s, f in CSF[i:]:
        cur = max(cur, s)
        if cur % F != 0:
            cur = cur + (f - (cur % f))
        # print("出発：{}".format(cur))
        cur += c
        # print("到着：{}".format(cur))
        ans_r.append(cur)

    return ans_r[-1]

for i in range(N):
    print(f(i))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

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

def f(i):
    ans_r = [0]
    cur = 0
    for c, s, f in CSF[i:]:
        cur = max(cur, s)
        if cur % F != 0:
            cur = cur + (f - (cur % F))
        # print("出発：{}".format(cur))
        cur += c
        # print("到着：{}".format(cur))
        ans_r.append(cur)

    return ans_r[-1]

for i in range(N):
    print(f(i))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

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

def f(i):
    ans_r = [0]
    cur = 0
    for c, s, f in CSF[i:]:
        cur = max(cur, s)
        if cur % F != 0:
            cur = cur + (F - (cur % F))
        # print("出発：{}".format(cur))
        cur += c
        # print("到着：{}".format(cur))
        ans_r.append(cur)

    return ans_r[-1]

for i in range(N):
    print(f(i))

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

def main():
    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):
        t = 0
        for j in range(i,N-1):
            wait = 0
            if t <= S[j]:
                wait = S[j] - t
            else:
                wait = F[j]%(t - S[j])%F[j]
            t += wait + C[j]
        print(t)
    print(0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

def main():
    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):
        t = 0
        for j in range(i,N-1):
            wait = 0
            if t <= S[j]:
                wait = S[j] - t
            else:
                wait = F[j] - (t - S[j])%F[j]
            t += wait + C[j]
        print(t)
    print(0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

def main():
    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):
        t = 0
        for j in range(i,N-1):
            wait = 0
            if t <= S[j]:
                wait = S[j] - t
            else:
                wait = (t-S[j])%F[j]
            t += wait + C[j]
        print(t)
    print(0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(n-1):
    if i==0:
        ans.append(st[0][0]+st[0][1])
    else:
        for j in range(len(ans)):
            if ans[j]>=st[i][1] and ans[j]%st[i][2]==0:
                ans[j] += st[i][0]
            elif ans[j]<st[i][1]:
                ans[j] = st[i][0]+st[i][1]
            else:
                a = (ans[j]-st[i][1])%st[i][2]
                a = ans[j]+a
                ans[j] = a+st[i][0]
        ans.append(st[i][0]+st[i][1])

ans.append(0)
for i in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
c = [list(map(int, input().split())) for _ in range(N - 1)]
anslst = [0] * N
for i in range(N - 1):
    ans = c[i][1] + c[i][0]
    for j in range(i + 1, N - 1):
        if ans <= c[j][1]:
            ans += (c[j][1] - ans) + c[j][0]
        else:
            tmp = ans - c[j][1]
            amari = tmp % c[j][2]
            if amari == 0:
                ans += c[j][0]
            else:
                ans += c[j][0] + amari

    anslst[i] = ans

for i in anslst:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
c = [list(map(int, input().split())) for _ in range(N - 1)]
anslst = [0] * N
for i in range(N - 1):
    ans = c[i][1] + c[i][0]
    for j in range(i + 1, N - 1):
        if ans <= c[j][1]:
            ans = c[j][1] + c[j][0]
        else:
            tmp = ans - c[j][1]
            amari = tmp % c[j][2]
            if amari == 0:
                ans += c[j][0]
            else:
                ans += c[j][0] + amari

    anslst[i] = ans

for i in anslst:
    print(i)

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())

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

Submission status: Wrong Answer

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

for i in range(n):
    time=0
    first=True
    for j in range(i,n):
        if first:
            time+=table[j][0]+table[j][1]
            first=False
        else:
            time+=table[j][0]+(time%table[j][2])
    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)

for start in range(n - 1):
    t = 0

    for i in range(start, n - 1):
        if S[i] <= t:
            t = t // F[i] + (t % F[i] != 0)
        else:
            t = S[i]

        t += C[i]

    print(t)

print(0)

Submission status: Wrong Answer

Solution code:
import math


def resolve():
    n = int(input())
    csf = list(list(map(int, input().split())) for _ in range(n - 1))
    for i in range(n - 1):
        now = 0
        for c, s, f in csf[i:]:
            if now <= s:
                now = s + c
            else:
                now = s + f * math.ceil((now - s) // f) + c
        print(now)
    print(0)


if __name__ == "__main__":
    resolve()

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)

ans = [0] * N

for i in range(N-1):
    cnt = i
    ans[i] += S[i] + C[i]
    while cnt<N-2:
        if ans[i]<S[cnt+1]:
            ans[i] = S[cnt+1]
        if ans[i]%F[cnt+1]!=0:
            ans[i] += ans[i]%F[cnt+1]
        ans[i] += C[cnt+1]
        cnt += 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(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

ans = [0] * N

for i in range(N-1):
    cnt = i
    ans[i] += S[i] + C[i]
    while cnt<N-2:
        if ans[i]<S[cnt+1]:
            ans[i] = S[cnt+1]
        ans[i] += C[cnt+1]
        cnt += 1

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

Submission status: Wrong Answer

Solution code:
# ABC084 C - Special Trains
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',C)
# print('S',S)
# print('F',F)

for i in range(N):
    ans = 0
    for j in range(i,N-1):
        if j == i:
            ans += S[i]
        # ans += C[j]
        if S[j] > ans:
            ans = S[j]
        else:
            if ans%F[j]==0:
                pass
            else:
                if j != N-2:
                    ans += F[j] - ans%F[j]
        ans += C[j]
    print(ans)

Submission status: Wrong Answer

Solution code:
# ABC084 C - Special Trains
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',C)
# print('S',S)
# print('F',F)

for i in range(N):
    ans = 0
    for j in range(i,N-1):
        if j == i:
            ans += S[i]
        # ans += C[j]
        if S[j] >= ans:
            ans = S[j]
        else:
            if ans%F[j]==0:
                pass
            else:
                if j != N-2:
                    ans += F[j] - ans%F[j]
        ans += C[j]
    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]   
                times+=lists[nums-1][0]
                nums+=1      
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    else:
        times=0
        while nums<n:
            if times>=lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    addadd=(times-lists[nums-1][1])%lists[nums-1][2]  
                    times+=nums-addadd
                times+=lists[nums-1][0]
                nums+=1                 
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=[list(map(int,input().split())) for _ in range(n-1)]  
for x in range(n):
    nums=x+1
    if nums==n:
        print(0)
    elif nums!=n:
        times=0
        while nums<n:
            if times>=lists[nums-1][1]:
                if (times-lists[nums-1][1])%lists[nums-1][2]!=0:
                    a=(times-lists[nums-1][1])%lists[nums-1][2]   
                times+=lists[nums-1][0]
                nums+=1      
            else:
                times=lists[nums-1][1]
                times+=lists[nums-1][0]   
                nums+=1 
        print(times)

Submission status: Wrong Answer

Solution code:
N = int(input())
Clist = []
Slist = []
Flist = []
for i in range(N-1):
    C, S, F = map(int, input().split())
    Clist.append(C)
    Slist.append(S)
    Flist.append(F)
    
for i in range(N):
    time = 0
    for j in range(i, N):
        if j != N-1:
            if time <= Slist[j]:
                time = Slist[j] + Clist[j]
            else:
                time = ((time//Flist[j])+1)*Flist[j]
    print(time)

Submission status: Wrong Answer

Solution code:
n=int(input())
csf=[[int(i) for i in input().split()] for j in range(n-1)]

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
C = [0] * N
S = [0] * N
F = [0] * (N - 1)
F.append(1)

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):
        time = max((time - S[j]) % F[j] + time, S[j]) + C[j]
    print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())
C = [0] * N
S = [0] * N
F = [0] * (N - 1)
F.append(1)

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):
        time = max(abs((time - S[j])) % F[j] + time, S[j]) + C[j]
    print(time)

Submission status: Wrong Answer

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

results = []
for i in range(n-1):
    cur = 0
    for j in range(i, n-1):
        k = max(0, (cur - setting[j][1]) // setting[j][2])
        cur = setting[j][0] + setting[j][1] + setting[j][2] * k
    results.append(cur)
results.append(0)
for result in results:
    print(result)