Problem:


Score : 300 points

Problem Statement

A railroad running from west to east in Atcoder Kingdom is now complete.

There are N stations on the railroad, numbered 1 through N from west to east.

Tomorrow, the opening ceremony of the railroad will take place.

On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated.

The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds.

Here, it is guaranteed that F_i divides S_i.

That is, for each Time t satisfying S_i≤t and t％F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where A％B denotes A modulo B, and there will be no other trains.

For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains.

Constraints

1≤N≤500

1≤C_i≤100

1≤S_i≤10^5

1≤F_i≤10

S_i％F_i=0

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
C_1 S_1 F_1
:
C_{N-1} S_{N-1} F_{N-1}

Output

Print N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x.

Sample Input 1

3
6 5 1
1 10 1

Sample Output 1

12
11
0

We will travel from Station 1 as follows:

5 seconds after the beginning: take the train to Station 2.

11 seconds: arrive at Station 2.

11 seconds: take the train to Station 3.

12 seconds: arrive at Station 3.

We will travel from Station 2 as follows:

10 seconds: take the train to Station 3.

11 seconds: arrive at Station 3.

Note that we should print 0 for Station 3.

Sample Input 2

4
12 24 6
52 16 4
99 2 2

Sample Output 2

187
167
101
0

Sample Input 3

4
12 13 1
44 17 17
66 4096 64

Sample Output 3

4162
4162
4162
0



Sample input:
3
6 5 1
1 10 1


Sample output:
12
11
0

Submission status: Wrong Answer

Solution code:
N = int(input())
C,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-1):
    T = S[i]
    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 += (T//F[j] +1)*F[j] + C[j]
    print(T)
print(0)

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-1):
    T = S[i]
    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 += (T//F[j] +1)*F[j]
    print(T)
print(0)

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-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 += (T//F[j] +1)*F[j]
    print(T)
print(0)

Submission status: Wrong Answer

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

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

print(0)

Submission status: Wrong Answer

Solution code:
class station:
    def __init__(self, speed, first, interval):
        self.speed = speed
        self.first = first
        self.interval = interval


def onboard_duration(station, start_time, first=False):
    # return the arrival_time at the next_station
    if first or start_time < station.first: # starting station or the first train is not departed from the station
        return station.first + station.speed
    else:
        return start_time + (start_time - station.first) % station.interval + station.speed


stations = []
for _ in range(int(input())-1):
    stations.append(station(*list(map(int, input().split()))))

for i in range(len(stations)):
    elapsed_time = 0
    for j in range(i, len(stations)):
        if elapsed_time == 0:
            elapsed_time = onboard_duration(stations[j], elapsed_time, first=True)
        else:
            elapsed_time = onboard_duration(stations[j], elapsed_time)
    print(elapsed_time)

print('0')

Submission status: Wrong Answer

Solution code:
import math
N=int(input())-1
c,s,f=[],[],[]
for i in range(N):
    a=list(map(int,input().split()))
    c.append(a[0])
    s.append(a[1])
    f.append(a[2])
for j in range(N):
    t=c[j]+s[j]
    for k in range(1,N-j):
        if s[j+k]>=t:
            t=s[j+k]+c[j+k]
        else:
            t=math.floor((t-s[j+k])/f[j+k])*f[j+k]+s[j+k]+c[j+k]
    print(t)
print("0")

Submission status: Wrong Answer

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

def station(time, i):
    if i == N:
        print(time)
        return
    c, s, f = CSF[i]
    nextTime = s + c if time <= s else time + (time % f) + c
    station(nextTime, i+1)

for i in range(N):
    station(0, i)
print(0)

Submission status: Wrong Answer

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

T = []
for n in range(N):
    t = 0
    for i in range(n, N-1):
        if S[i] >= t:
            d = S[i] - t + C[i]
        else:
            d = ((t - S[i])%F[i]) + C[i]
        t += d
    T.append(t)

for t in T:
    print(t)

Submission status: Wrong Answer

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

T = []
for n in range(N):
    t = 0
    for i in range(n, N-1):
        if S[i] >= t:
            d = S[i] - t + C[i]
        else:
            d = ((t - S[i])%F[i]) + C[i]
        t += d
    T.append(t)

print(T)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    station_count = int(input())
    c, s, f = list(), list(), list()

    # HACK: More smarter.
    for _ in range(station_count - 1):
        line = list(map(int, input().split()))
        c.append(line[0])
        s.append(line[1])
        f.append(line[2])

    total_elapsed_times = list()

    # HACK: More smarter.
    for i in range(station_count):
        if i < station_count - 1:
            total_elapsed_times.append(s[i])
        else:
            total_elapsed_times.append(0)

    for j in range(station_count - 1):

        for k in range(j, station_count - 1):
            if total_elapsed_times[j] < s[k]:
                total_elapsed_times[j] = s[k]
            elif total_elapsed_times[j] % f[j] == 0:
                pass
            else:
                total_elapsed_times[j] += f[k] - (total_elapsed_times[j] % f[k])

            total_elapsed_times[j] += c[k]

    for total_elapsed_time in total_elapsed_times:
        print(total_elapsed_time)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    station_count = int(input())
    c, s, f = list(), list(), list()

    # HACK: More smarter.
    for _ in range(station_count - 1):
        line = list(map(int, input().split()))
        c.append(line[0])
        s.append(line[1])
        f.append(line[2])

    total_elapsed_times = list()

    # HACK: More smarter.
    for i in range(station_count):
        if i < station_count - 1:
            total_elapsed_times.append(s[i])
        else:
            total_elapsed_times.append(0)

    for j in range(station_count - 1):
        for k in range(j, station_count - 1):
            if total_elapsed_times[j] >= s[k]:
                total_elapsed_times[j] += c[k]
            else:
                total_elapsed_times[j] = 0
                total_elapsed_times[j] += s[k]
                total_elapsed_times[j] += c[k]

    for total_elapsed_time in total_elapsed_times:
        print(total_elapsed_time)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    station_count = int(input())
    c, s, f = list(), list(), list()

    # HACK: More smarter.
    for _ in range(station_count - 1):
        line = list(map(int, input().split()))
        c.append(line[0])
        s.append(line[1])
        f.append(line[2])

    total_elapsed_times = list()

    # HACK: More smarter.
    for i in range(station_count):
        if i < station_count - 1:
            total_elapsed_times.append(s[i])
        else:
            total_elapsed_times.append(0)

    for j in range(station_count - 1):
        for k in range(j, station_count - 1):
            if (total_elapsed_times[j] >= s[k]) and (total_elapsed_times[j] % f[k] == 0):
                total_elapsed_times[j] += c[k]
            else:
                total_elapsed_times[j] = 0
                total_elapsed_times[j] += s[k]
                total_elapsed_times[j] += c[k]

    for total_elapsed_time in total_elapsed_times:
        print(total_elapsed_time)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    station_count = int(input())
    c, s, f = list(), list(), list()

    # HACK: More smarter.
    for _ in range(station_count - 1):
        line = list(map(int, input().split()))
        c.append(line[0])
        s.append(line[1])
        f.append(line[2])

    total_elapsed_times = list()

    # HACK: More smarter.
    for i in range(station_count):
        if i < station_count - 1:
            total_elapsed_times.append(s[i])
        else:
            total_elapsed_times.append(0)

    for j in range(station_count - 1):
        for k in range(j, station_count - 1):
            print(j, total_elapsed_times[j])
            if (total_elapsed_times[j] >= s[k]) and (total_elapsed_times[j] % f[k] == 0):
                total_elapsed_times[j] += c[k]
            else:
                total_elapsed_times[j] = 0
                total_elapsed_times[j] += s[k]
                total_elapsed_times[j] += c[k]

    for total_elapsed_time in total_elapsed_times:
        print(total_elapsed_time)

Submission status: Wrong Answer

Solution code:
N = int(input())-1
timeLine = [[0 for x in range(3)] for y in range(N)]
for i in range(N):
    tmp = input().split()
    timeLine[i][0],timeLine[i][1],timeLine[i][2] = int(tmp[0]),int(tmp[1]),int(tmp[2])
for j in range(N):
    total = timeLine[j][0] + timeLine[j][1]
    now = j+1
    while now <= (N-1):
        if timeLine[now][1] >= total:
            total = timeLine[now][1] + timeLine[now][0]
        else:
            if timeLine[now][1] + timeLine[now][2] >= total:
                total = timeLine[now][0] + timeLine[now][1] + timeLine[now][2]
            else:
                n = int((total-timeLine[now][1])/timeLine[now][2]) + 1
                total = timeLine[now][0] + timeLine[now][1] + timeLine[now][2] * n
        now +=1
    print(total)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())-1
timeLine = [[0 for x in range(3)] for y in range(N)]
for i in range(N):
    tmp = input().split()
    timeLine[i][0],timeLine[i][1],timeLine[i][2] = int(tmp[0]),int(tmp[1]),int(tmp[2])
for j in range(N):
    total = timeLine[j][0] + timeLine[j][1]
    now = j+1
    while now <= (N-1):
        if timeLine[now][1] >= total:
            total = timeLine[now][1] + timeLine[now][0]
        else:
            if timeLine[now][1] + timeLine[now][2] >= total:
                total = timeLine[now][1] + timeLine[now][2]
            else:
                n = int((total-timeLine[now][1])/timeLine[now][2]) + 1
                total = timeLine[now][1] + timeLine[now][2] * n
        now +=1
    print(total)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())-1
timeLine = [[0 for x in range(3)] for y in range(N)]
for i in range(N):
    tmp = input().split()
    timeLine[i][0],timeLine[i][1],timeLine[i][2] = int(tmp[0]),int(tmp[1]),int(tmp[2])
for j in range(N):
    total = timeLine[j][0] + timeLine[j][1]
    now = j+1
    while now <= (N-1):
        if timeLine[now][1] >= total:
            total = timeLine[now][1] + timeLine[now][0]
        else:
            wait = int((total - timeLine[now][1]) % timeLine[now][2])
            total += (wait + timeLine[now][0])
        now +=1
    print(total)
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())-1
timeLine = [[0 for x in range(3)] for y in range(N)]
for i in range(N):
    tmp = input().split()
    timeLine[i][0],timeLine[i][1],timeLine[i][2] = int(tmp[0]),int(tmp[1]),int(tmp[2])
for j in range(N):
    total = timeLine[j][0] + timeLine[j][1]
    now = j+1
    while now <= (N-1):
        if timeLine[now][1] >= total:
            total = timeLine[now][1] + timeLine[now][0]
        else:
            wait = (total - timeLine[now][1]) % timeLine[now][2]
            total += wait + timeLine[now][0]
        now +=1
    print(total)
print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [list(map(int,input().split())) for _ in range(n - 1)]
ans = []
time = 0
for i,j in enumerate(arr):
    for k in arr[i+1:]:
        time += k[0]
    sum_ = sum(j[:-1]) + time
    ans.append(sum_)
    time = 0
ans.append(0)

for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [list(map(int,input().split())) for _ in range(n - 1)]
ans = []
time = 0
print(arr)
for i,j in enumerate(arr):
    for k in arr[i+1:]:
        time += k[0]
    sum_ = sum(j[:-1]) + time
    ans.append(sum_)
    time = 0
ans.append(0)

for i in ans:
    print(i)

Submission status: Wrong Answer

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

time = [0] * N


for i, station in enumerate(stations):
    C, S, F = station
    for j in range(i + 1):
        if S > time[j]:
            time[j] = S + C
        else:
            time[j] += F - (time[j] % F) + C

[ print(t) for t in time ]

Submission status: Wrong Answer

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

time = [ S for C, S, F in stations]


for i, station in enumerate(stations):
    C, S, F = station
    for j in range(i + 1):
        if S > time[j]:
            time[j] = S + C
        else:
            time[j] += (time[j] % F) + C

[ print(t) for t in 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 i in range(N):
    sumTime = 0
    stationNumber = i
    #print("(●・▽・●)",stationNumber)
    while stationNumber < N - 1:
        #print("(●・▽・●)(●・▽・●)", stationNumber, sumTime)
        if sumTime == 0:
            sumTime += s[stationNumber]

        if (sumTime - s[stationNumber]) % f[stationNumber] == 0:
            sumTime += c[stationNumber]
            stationNumber += 1
        else:
            sumTime += 1

    print(sumTime)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = []
time = []
oki = []
eki = 1
for i in range(n-1):
    a,b,c = map(int,input().split())
    lis.append(a)
    time.append(b)
    oki.append(c)

for m in range(n):

    cou = 0
    k = m
    while k < n-1 :
        if cou < time[k]:
            cou = time[k]
        if (cou -time[k])%oki[k] != 0:
            s =oki[k] -( (cou - time[k])% oki[k])
        cou += lis[k]
        k += 1
    if m == n-1:
        print("0")
    else:
        print(cou)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
C, S, F = [], [], []
for i in range(N-1):
	C_S_F = [int(num) for num in raw_input().split()]
	C.append(C_S_F[0])
	S.append(C_S_F[1])
	F.append(C_S_F[2])

def calc_time(i):
	Y = [None] * N
	Y[i] = S[i] + C[i]
	for point in range(i, N-2):
		#print point, Y[point]
		Y[point+1] = max((Y[point] / F[point+1]) * F[point+1], 
			S[point+1]) + C[point+1]
		#print i, point+1, Y[point+1], C[point+1]
	return Y[N-2]

for i in range(N-1):
	print calc_time(i)

print 0

Submission status: Wrong Answer

Solution code:
"""
5
3 2 2 4 1
1 2 2 2 1
"""

n = int(input())
array = [[int(x) for x in input().split()], [int(x) for x in input().split()]]

res = 0
for i in range(n):
    tmp = sum(array[0][:i+1])+sum(array[1][i:])
    if tmp > res:
        res = tmp
print(res)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def main():
    n = int(input())
    csf = tuple(tuple(map(int, line.split())) for line in sys.stdin.readlines())
    ans = []
    for i in range(n - 1):
        t = 0
        for c, s, f in csf[i:]:
            if t < s:
                t = s
            t = s + ((t - s) // f) * f + c
        ans.append(t)
    ans.append(0)
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:

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

    T = []
    t = 0
    C = C[::-1]
    F = F[::-1]
    for i in range(N-1):
        r = C[i]%F[i]
        t += C[i]
        if r != 0:
            if i != 0:
                t += F[i] - r-1
        T.append(t)

    T = T[::-1]

    total = []
    for i in range(N-1):
            total.append(S[i]+T[i])

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

        else:
            print (max(total[i:]))

if __name__ == "__main__":
    # global stime
    # stime = time.clock()
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())

    times, start, interval = [], [], []
    for i in range(N-1):
        t, s, i = list(map(int, input().split()))
        times.append(t)
        start.append(s)
        interval.append(i)

    for src_station_idx in range(N-1):
        current_total_time = start[src_station_idx] + times[src_station_idx]

        for via_station_idx in range(src_station_idx+1, N-1):
            moving_time = times[via_station_idx]

            # 次に来る電車までの待ち時間を計測する
            if current_total_time <= start[via_station_idx]:
                waiting_time = start[via_station_idx] - current_total_time
            else:
                waiting_time = (current_total_time - start[via_station_idx]) % interval[via_station_idx]

            current_total_time += waiting_time + moving_time

        print(current_total_time)

    print(0)



main()

Submission status: Wrong Answer

Solution code:
from inspect import currentframe

def chkprint(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

def main():
    N = int(input())

    times, start, interval = [], [], []
    for i in range(N-1):
        t, s, i = list(map(int, input().split()))
        times.append(t)
        start.append(s)
        interval.append(i)

    for src_station_idx in range(N-1):
        current_total_time = start[src_station_idx] + times[src_station_idx]

        for via_station_idx in range(src_station_idx+1, N-1):
            moving_time = times[via_station_idx]

            # 次に来る電車までの待ち時間を計測する
            if current_total_time <= start[via_station_idx]:
                waiting_time = start[via_station_idx] - current_total_time
            else:
                waiting_time = current_total_time % interval[via_station_idx]

            current_total_time += waiting_time + moving_time

        print(current_total_time)

    print(0)



main()

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0]*n
c, s, f = [], [], []
for i in range(n - 1):
    ct, st, ft = list(map(int, input().split()))
    c.append(ct)
    s.append(st)
    f.append(ft)

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = [0]*n
c, s, f = [], [], []
for i in range(n - 1):
    ct, st, ft = list(map(int, input().split()))
    c.append(ct)
    s.append(st)
    f.append(ft)

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

time_list = []

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

time_list.append(0)

for time in time_list:
    print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())

time_list = []

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

time_list.append(0)

for time in time_list:
    print(time)

Submission status: Wrong Answer

Solution code:
N = int(input())

time_list = []

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

time_list.append(0)

for time in time_list:
    print(time)

Submission status: Wrong Answer

Solution code:

def main():
    N = int(input())

    x = [[int(a) for a in input().split()] for i in range(N - 1)]

    for i in range(N):
        time = 0
        for a in range(i, N-1):
            C = x[a][0]
            S = x[a][1]
            F = x[a][2]
            # time = max(time, S)
            if time < S:
                time = S
            if time % F == 0:
                pass
            else:
                time == time + F - time % F
            time += C
        print(time)

main()

Submission status: Wrong Answer

Solution code:

def main():
    N = int(input())

    x = [[int(a) for a in input().split()] for i in range(N - 1)]

    for i in range(N):
        time = 0
        for a in range(i, N-1):
            C = x[a][0]
            S = x[a][1]
            F = x[a][2]
            time = max(time, S)
            if time % F == 0:
                pass
            else:
                time == time + F - time % F
            time += C
        print(time)

main()

Submission status: Wrong Answer

Solution code:

def main():
    N = int(input())

    x = [[int(a) for a in input().split()] for i in range(N - 1)]

    for i in range(N):
        time = 0
        for a in range(i, N-1):
            C = x[a][0]
            S = x[a][1]
            F = x[a][2]
            time = max(time, S)
            time += (time + S) % F
            time += C
        print(time)

main()

Submission status: Wrong Answer

Solution code:

def main():
    N = int(input())

    x = [[int(a) for a in input().split()] for i in range(N - 1)]

    for i in range(N):
        time = 0
        for a in range(i, N-1):
            C = x[a][0]
            S = x[a][1]
            F = x[a][2]
            time = max(time, S)
            time += time % F
            time += C
        print(time)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = []
ans = []
for v in range(n-1):
    c, t, f = map(int,input().split())
    te = [c, t, f]
    nums.append(te)

for q in range(0,n-1):
    if(q==n-2):
        time = 0
        time += nums[q][0]
        time += nums[q][1]
        ans.append(time)
        break;
    time = 0
    time += nums[q][0]
    time += nums[q][1]
    for t in range(q+1,n-1):
        p = nums[t][1];
        while(time > p):
            p += nums[t][2]
        p += nums[t][0]
        time = p
    ans.append(p)

ans.append(0)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = []
ans = []
for v in range(n-1):
    c, t, f = map(int,input().split())
    te = [c, t, f]
    nums.append(te)

print(nums)

for q in range(0,n-1):
    if(q==n-2):
        time = 0
        time += nums[q][0]
        time += nums[q][1]
        ans.append(time)
        break;
    time = 0
    time += nums[q][0]
    time += nums[q][1]
    for t in range(q+1,n-1):
        p = nums[t][1];
        while(time > p):
            p += nums[t][2]
        p += nums[t][0]
        time = p
    ans.append(p)

ans.append(0)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
t = 0
st = 0
cn = []
sn = []
fn = []

for i in range(n-1):
  c,s,f = map(int,input().split())
  cn.append(c)
  sn.append(s)
  fn.append(f)

for j in range(n-1):
    for i in range(j,n-1):
      st = sn[i]
      if t <= sn[i]:
        t = sn[i]
      else:
        while t <= st :
          st += fn[i]
      t += cn[i]
    print(t)
    t = 0

print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list()

for i in range(0,N-1):
    X.append(list(map(int,input().strip().split(" "))))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X =list()

for i in range(0,N-1):
    X.append(list(map(int,input().strip().split(" "))))
    
X0 =list()

for i in range(0,N-1):
    X0.append(X[i][0])


for i in range(0,N-1):
    X1 =list()
    for j in range(i,N-1):
        X1.append(X[j][1]+sum(X0[j::]))
    print(max(X1))
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
X =list()

for i in range(0,N-1):
    X.append(list(map(int,input().strip().split(" "))))
    
X0 =list()

for i in range(0,N-1):
    X0.append(X[i][0])


for i in range(0,N-1):
    X1 =list()
    for j in range(i,N-1):
        X1.append(X[i][1]+sum(X0[i::]))
    print(max(X1))
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
X =list()

for i in range(0,N-1):
    X.append(list(map(int,input().strip().split(" "))))
    
X0 =list()

for i in range(0,N-1):
    X0.append(X[i][0])
    
for i in range(0,N-1):
    print(X[i][1]+sum(X0[i::]))
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    x, y, z = map(int, input().split(" "))
    C.append(x)
    S.append(y)
    F.append(z)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
n = 0
C = []
S = []
F = []
T = []
while n < N-1:
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
    n = n + 1
n = 0
while n < N-1:
    t = S[n]
    T.append(t)
    for i in range(n,N-1):
        if T[n]<=S[i]:
            T[n] = S[i]
        elif T[n]%F[i]:
            a = T[n]%F[i]
            T[n] = T[n] + a
        T[n] = T[n] + C[i]
    print(T[n])
    n = n+1
print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = 0
C = []
S = []
F = []
T = []
while n < N-1:
    c,s,v = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(v)
    n = n + 1
n = 0
while n < N-1:
    t = S[n]
    T.append(t)
    for i in range(n,N-1):
        if T[n]<S[i]:
            T[n] = S[i]
        elif T[n]%F[i]:
            a = T[n]%F[i]
            T[n] = T[n] + a
        T[n] = T[n] + C[i]
    print(T[n])
    n = n+1
print(0)