Problem:


Score : 300 points

Problem Statement

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

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

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

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

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

Here, it is guaranteed that F_i divides S_i.

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

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

Constraints

1≤N≤500

1≤C_i≤100

1≤S_i≤10^5

1≤F_i≤10

S_i％F_i=0

All input values are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

3
6 5 1
1 10 1

Sample Output 1

12
11
0

We will travel from Station 1 as follows:

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

11 seconds: arrive at Station 2.

11 seconds: take the train to Station 3.

12 seconds: arrive at Station 3.

We will travel from Station 2 as follows:

10 seconds: take the train to Station 3.

11 seconds: arrive at Station 3.

Note that we should print 0 for Station 3.

Sample Input 2

4
12 24 6
52 16 4
99 2 2

Sample Output 2

187
167
101
0

Sample Input 3

4
12 13 1
44 17 17
66 4096 64

Sample Output 3

4162
4162
4162
0



Sample input:
3
6 5 1
1 10 1


Sample output:
12
11
0

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
C, S, F = [], [], []
for i in range(N-1):
  a = input().split()
  C.append(a[0])
  S.append(a[1])
  F.append(a[2])

for i in range(N-1):
  sum = 0
  for j in range(N-1):
    sum += int(C[N-2-j])
  print( int(S[i]) + sum )
print("0")

Submission status: Wrong Answer

Solution code:
ans = [0]
N = int(input())
train = [list(map(int,input().split())) for _ in range(N-1)]
P = 0
t = 0
for i in range(N-2,-1,-1):
    s = train[i][0] + train[i][1]
    if i != (N-2):
        for j in range(N-2,i,-1):
            s -= P % train[j][2]
        s += P
    if s < ans[0]:
        s = ans[0]
    ans.insert(0,s)
    P += train[i][0]
    Q = train[i][1]
    R = train[i][2]
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
def solve():
    while 1:
        try:
            N = int(input())
            if N == 1:
                print(0)
                raise EndLoop
            C = []
            S = []
            F = []
            for _ in range(N - 1):
                tmp_c, tmp_s, tmp_f = list(map(int, input().split(" ")))
                C.append(tmp_c)
                S.append(tmp_s)
                F.append(tmp_f)

            Answer = []
            for i in range(N - 2):
                current_time = C[i] + S[i]
                for j in range(i + 1, N - 1):
                    if current_time < S[j]:
                        current_time += C[j] + (S[j] - current_time)
                    elif current_time >= S[j] and current_time % F[j] == 0:
                        if current_time % F[j] == 0:
                            current_time += C[j]
                        else:
                            current_time += F[j] - (current_time % F[j])

                    if j == N - 2:
                        Answer.append(current_time)

            Answer.append(S[-1] + C[-1])
            Answer.append(0)
            for ele in Answer:
                print(ele)
            break
        except:
            break


solve()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n-1)]
    r = []
    for i in range(n-1):
        s = a[i][0] + a[i][1]
        for j in range(i+1,n-1):
            if s <= a[j][1]:
                s = a[j][1]
            else:
                if s % a[j][2] > 0:
                    s += s - s % a[j][2]
            s += a[j][0]
        r.append(s)
    r.append(0)

    return '\n'.join(map(str,r))

print(main())

Submission status: Wrong Answer

Solution code:
def solve():
    while 1:
        try:
            N = int(input())
            if N == 1:
                print(0)
                raise EndLoop
            C = []
            S = []
            F = []
            for _ in range(N - 1):
                tmp_c, tmp_s, tmp_f = list(map(int, input().split(" ")))
                C.append(tmp_c)
                S.append(tmp_s)
                F.append(tmp_f)

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

                    if j == N - 2:
                        Answer.append(current_time)

            Answer.append(S[-1] + C[-1])
            Answer.append(0)
            for ele in Answer:
                print(ele)
            break
        except:
            break


solve()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n-1)]
    r = []
    for i in range(n-1):
        s = a[i][0] + a[i][1]
        for j in range(i+1,n-1):
            if s <= a[j][1]:
                s = a[j][1]
            else:
                s += s % a[j][2]
            s += a[j][0]
        r.append(s)
    r.append(0)

    return '\n'.join(map(str,r))

print(main())

Submission status: Wrong Answer

Solution code:
#coding:utf-8
 
#A, B = map(int,raw_input().split())
N = int(raw_input())
 
Time = [0 for i in range(N)]
C, S, F = map(int,raw_input().split())
Time[0] += S
for i in range(1,N-1):
    Cnew, S, F = map(int,raw_input().split())
    Time[i] += S
 
    for j in range(i):
        if Time[j] > S:
            Time[j] = Time[j] + C
            if (Time[j] - S) % F == 0:
                pass
            else:
                Amari = F - ((Time[j] - S) % F)
                Time[j] = Time[j] + Amari
        else:
            Time[j] = S
    C = Cnew
 
for i in range(N-1):
    Time[i] += C
    print Time[i]
print Time[N-1]

Submission status: Wrong Answer

Solution code:
#coding:utf-8

#A, B = map(int,raw_input().split())
N = int(raw_input())

Time = [0 for i in range(N)]
C, S, F = map(int,raw_input().split())
Time[0] += S
for i in range(1,N-1):
    Cnew, S, F = map(int,raw_input().split())
    Time[i] += S

    for j in range(i):
        if Time[j] > S:
            Time[j] = Time[j] + C
            if (Time[j] - S) % F == 0:
                pass
            else:
                Amari = F - ((Time[j] - S) % F)
                Time[j] = Time[j] + Amari
        else:
            Time[j] = S
    C = Cnew

for i in range(N-1):
    Time[i] += C
    print Time[i]

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())

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

'''
print('C ', C)
print('S ', S)
print('F ', F)
'''

ans = {}
for i in range(N-1):
    ans[i] = S[i]
    for j in range(N-1-i):
        #ans[i] += C[j+i]
        if ans[i] >= S[j+i] and ans[i] == S[j+i]:
            ans[i] += C[j+i]
        elif ans[i]>S[i+j] and ans[i] % F[j+i] == 0:
            ans[i] += C[j+i]
        elif ans[i]>S[i+j] and ans[i] % F[j+i] != 0:
            ans[i] = S[j+i] + F[j+i]
        elif ans[i] < S[j+i]:
            ans[i] = S[j+i] + C[j+i]
for k in ans:
    print(ans[k])

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

Submission status: Wrong Answer

Solution code:
def solve():
    while 1:
        try:
            N = int(input())
            if N == 1:
                print(0)
                raise EndLoop
            C = []
            S = []
            F = []
            for _ in range(N - 1):
                tmp_c, tmp_s, tmp_f = list(map(int, input().split(" ")))
                C.append(tmp_c)
                S.append(tmp_s)
                F.append(tmp_f)

            Answer = []
            for i in range(N - 2):
                current_time = C[i] + S[i]
                for j in range(i + 1, N - 1):
                    if current_time >= S[j] and current_time % F[j] == 0:
                        current_time += C[j]
                    else:
                        if current_time < S[j]:
                            current_time += C[j] + S[j] - current_time
                        else:
                            current_time += F[j] - (current_time % F[j])

                    if j == N - 2:
                        Answer.append(current_time)

            Answer.append(S[-1] + C[-1])
            Answer.append(0)
            for ele in Answer:
                print(ele)
            break
        except:
            break


solve()

Submission status: Wrong Answer

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

for i in range(n):
    AnsSec = 0
    Now_Station = i
    while Now_Station < n - 1:
        if AnsSec > csf[Now_Station][1]:
            if csf[Now_Station][2] % AnsSec != 0:
                AnsSec += csf[Now_Station][2] - (AnsSec % csf[Now_Station][2])
        else:
            AnsSec += csf[Now_Station][1] - AnsSec
        AnsSec += csf[Now_Station][0]
        Now_Station += 1
    print(AnsSec)

Submission status: Wrong Answer

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

for i in range(n):
    AnsSec = 0
    Now_Station = i
    while Now_Station < n - 1:
        if AnsSec > csf[Now_Station][1]:
            if csf[Now_Station][2] % AnsSec != 0:
                AnsSec += csf[Now_Station][2] - (AnsSec % csf[Now_Station][2] )
        else:
            AnsSec += csf[Now_Station][1] - AnsSec
        AnsSec += csf[Now_Station][0]
        Now_Station += 1
    print(AnsSec)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())

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

'''
print('C ', C)
print('S ', S)
print('F ', F)
'''

ans = {}
for i in range(N-1):
    ans[i] = S[i]
    for j in range(N-1-i):
        #ans[i] += C[j+i]
        if ans[i] >= S[j+i] and ans[i] == S[j+i]:
            ans[i] += C[j+i]
        elif ans[i]>S[i] and ans[i] % F[j+i] == 0:
            ans[i] += C[j+i]
        elif ans[i]>S[i] and ans[i] % F[j+i] != 0:
            ans[i] = S[j+i] + C[j+i]
        elif ans[i] < S[j+i]:
            ans[i] = S[j+i] + C[j+i]
for k in ans:
    print(ans[k])

print(0) # 最後の駅

Submission status: Wrong Answer

Solution code:
import re
import math
num = int(input())
a = []
b = []
c = []
for i in range(num-1):
    x,y,z = map(int,input().split(" "))
    a.append(x)
    b.append(y)
    c.append(z)
for i in range(num-1):
    time = 0
    for j in range(i,num-1):
        if(time < b[j]):
            time = b[j]
        time += a[j]
        # print(time,j)
    print(time)
print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

n = int(input())
c = np.zeros((n-1), dtype=np.int)
s = np.zeros((n-1), dtype=np.int)
f = np.zeros((n-1), dtype=np.int)
for i in range(n-1):
    c[i], s[i], f[i] = map(int, input().split(" "))

t = np.zeros(n, dtype=np.int)
for i in range(n-1):
    t[i] = s[i] + c[i]
    for j in range((i+1), (n-1), 1):
        if(s[j] >= t[i]):
            t[i] = s[j]
        else:
            t[i] += t[i] % f[j]
        t[i] += c[j]

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

Submission status: Wrong Answer

Solution code:
ans = [0]
N = int(input())
train = [list(map(int,input().split())) for _ in range(N-1)]
P = 0
for i in range(N-2,-1,-1):
    s = train[i][0] + train[i][1]
    if i != (N-2):
        for j in range(N-2,i,-1):
            s += s % train[j][2]
        s += P
    if s < ans[0]:
        s = ans[0]
    ans.insert(0,s)
    P += train[i][0]
    Q = train[i][1]
    R = train[i][2]
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
class Train():
    
    def __init__(self,c,start,frequecncy):
        self.c = c
        self.start = start
        self.frequecncy = frequecncy
    
    def solve(self,t):
        if t < self.start:
            return self.start + self.c
        else:
            c = 0
            while t < self.frequecncy + t:
                if (t - self.start) % self.frequecncy == 0:
                    return t
                t += 1


trains = []
for h,i in enumerate(sys.stdin):
    trains.append((Train(*map(int, i.split()))))

routes = []

for i in range(N-1):
    routes.append(range(i, N-1))

for i,j in enumerate(routes):
    t = 0
    if j == N - 1:
        print(0)
        break
    for k in j:
        # print(k)
        t += trains[k].solve(t)
    print(t)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

#A, B = map(int,raw_input().split())
N = int(raw_input())

Time = [0 for i in range(N)]
C, S, F = map(int,raw_input().split())
Time[0] += S
for i in range(1,N-1):
    Cnew, S, F = map(int,raw_input().split())
    Time[i] += S

    for j in range(i):
        if Time[j] > S:
            Time[j] = Time[j] + C
            Amari = F - ((Time[j] - S) % F)
            Time[j] = Time[j] + Amari
        else:
            Time[j] = S
    C = Cnew

for i in range(N-1):
    Time[i] += C
    print Time[i]

Submission status: Wrong Answer

Solution code:
N = int(input())						# 5

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

#print("C", C)
#print("S", S)
#print("F", F)

ans=[0]*(N+1)





# n駅からn+1駅へ移動した時の到着時刻
def nextArrive(n, iArrive, C,S,F):
	iAns = 0
	if iArrive < S[n]:
		#⇒まだ
		iAns = S[n] + C[n]
		#print("A", n, iAns, S[n], C[n])
	else:
		#⇒順次運行中
		iWait = iArrive % F[n]
		iAns = iArrive + iWait + C[n]
		#print("B", n, iArrive, iWait, C[n], iAns)
	
	return iAns

iArrive=0
for i in range(1, N):
	iArrive = S[i]
	for n in range(i, N):
		iArrive = nextArrive(n, iArrive, C,S,F)

	ans[i] = iArrive






#print(ans)

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

Submission status: Wrong Answer

Solution code:
def my_cal(I):
    if I==n-1:
        return 0
    else:
        COUNT = I
        TIME = star[COUNT]+dist[COUNT]
        while COUNT < n-2:
            if TIME<star[COUNT+1]:
                TIME = star[COUNT+1]+dist[COUNT+1]
                COUNT += 1
            else:
                TIME += (TIME-star[COUNT+1])%div[COUNT+1]
                TIME += dist[COUNT+1]
                COUNT += 1
        return(TIME)
    
if __name__ == '__main__':
    n = int(input())
    dist = []
    star = []
    div = []
    for i in range(n-1):
        d,s,v = input().split(" ")
        dist.append(int(d))
        star.append(int(s))
        div.append(int(v))
    ans = list(map(my_cal, [i for i in range(n)]))
    for ele in ans:
        print(ele)

Submission status: Wrong Answer

Solution code:

def solve():
    while 1:
        try:
            N = int(input())
            if N == 1:
                print(0)
                raise EndLoop
            C = []
            S = []
            F = []
            for _ in range(N - 1):
                tmp_c, tmp_s, tmp_f = list(map(int, input().split(" ")))
                C.append(tmp_c)
                S.append(tmp_s)
                F.append(tmp_f)

            Answer = []
            for i in range(N - 2):
                current_time = C[i] + S[i]
                for j in range(i + 1, N - 1):
                    if current_time >= S[j] and current_time % F[j] == 0:
                        current_time += C[j]
                    else:
                        if current_time < S[j]:
                            current_time += C[j] + S[j] - current_time
                        else:
                            i = 0
                            while (S[j] + F[j] * i) % current_time:
                                i += 1
                            current_time += C[j] + (S[j] + F[j] * i - current_time)

                    if j == N - 2:
                        Answer.append(current_time)

            Answer.append(S[-1] + C[-1])
            Answer.append(0)
            for ele in Answer:
                print(ele)
            break
        except:
            break


solve()

Submission status: Wrong Answer

Solution code:
n = int(input())

cs = []
ss = []
fs = []

for i in range(n-1):
    c, s, f = map(int, input().split(' '))
    cs.append(c)
    ss.append(s)
    fs.append(f)

for i in range(n-1):
    t = 0
    for j in range(i, n - 1):
        if t < ss[j]:
            t = ss[j]
        else:
            if t % fs[j] != 0:
                t += fs[j] - (t % fs[j])
        t += cs[j]
    print(t)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []

for i in range(n):
  l.append(list(map(int, input().split())))
  if i == n-2:
    break

for i in range(n-1):
  if i == n-1:
    break
  sum = l[i][0] + l[i][1]
  for j in range(i+1, n-1):
    if  l[j][1] > sum:
      sum = l[j][1] + l[j][0]
      break
    diff = sum - l[j][1]
    if not (sum - l[j][1]) % l[j][2] == 0:
      if diff < l[j][2]:
        sum += l[j][2] - diff
      elif diff > l[j][2]:
        sum += l[j][2] - diff % l[j][2]
    sum += l[j][0]


  print(sum)

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(0, N-1):
    t = S[i]
    for j in range(i, N-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 = []
for i in range(n - 1):
    csf.append(list(map(int, input().split())))

for i in range(n):
    AnsSec = 0
    Now_Station = i
    while Now_Station < n - 1:
        if AnsSec > csf[Now_Station][1]:
            if csf[Now_Station][2] % AnsSec != 0:
                AnsSec += csf[Now_Station][2] - (csf[Now_Station][2] % AnsSec)
        else:
            AnsSec += csf[Now_Station][1] - AnsSec
        AnsSec += csf[Now_Station][0]
        Now_Station += 1
    print(AnsSec)

Submission status: Wrong Answer

Solution code:
ans = [0]
N = int(input())
train = [list(map(int,input().split())) for _ in range(N-1)]
P = 0
for i in range(N-2,-1,-1):
    s = train[i][0] + train[i][1]
    if i != (N-2):
        s += s % R
        s += P
    if s < ans[0]:
        s = ans[0]
    ans.insert(0,s)
    P += train[i][0]
    Q = train[i][1]
    R = train[i][2]
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):
    t_C, t_S, t_F = map(int, input().split())
    C.append(t_C)
    S.append(t_S)
    F.append(t_F)

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

Submission status: Wrong Answer

Solution code:
ans = [0]
N = int(input())
train = [list(map(int,input().split())) for _ in range(N-1)]
P = 0
for i in range(N-2,-1,-1):
    s = train[i][0] + train[i][1]
    if i != (N-2):
        (s-Q) % R
        s += P
    if s < ans[0]:
        s = ans[0]
    ans.insert(0,s)
    P += train[i][0]
    Q = train[i][1]
    R = train[i][2]
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
I = [[int(i) for i in input().split()] for i in range(N - 1)]
I.reverse()
result = [0 for i in range(N)]
rest = 0
for i in range(0, N - 1):
  if I[i][0] + I[i][1] + rest > result[i]:
    result[i + 1] = I[i][0] + I[i][1] + rest
    rest += I[i][0]
  else:
    result[i + 1] = result[i]
result.reverse()
for i in range(N):
  print(result[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
table = [[0 for i in range(3)] for k in range(n-1)]
for i in range(n-1):
	c,s,f = map(int,input().split())
	table[i][0] = c
	table[i][1] = s
	table[i][2] = f
for i in range(n-1):
	total = table[i][1]+table[i][0]
	for k in range(i+1,n-1):
		if total <= table[k][1]:
			total = table[k][1] + table[k][0]
		else:
			sur = total%table[k][2]
			total = total + sur + table[k][0]
	print(total)
print('0')

Submission status: Wrong Answer

Solution code:
n = int(input())
X = [[int(i) for i in input().split()] for i in range(1,n,1)]
ans=[0 for i in range(n)]
for j in range(n):
	for i in range(j,n-1,1):
		if ans[j]>=X[i][1]:
			if ans[j]%X[i][2]==0:
				ans[j]=ans[j]+X[i][0]
			else:
				ans[j]=ans[j]+X[i][0]+X[i][0]-ans[j]%X[i][2]

		else:
			ans[j]=X[i][1]+X[i][0]


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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

#A, B = map(int,raw_input().split())
N = int(raw_input())

Time = [0 for i in range(N)]
C, S, F = map(int,raw_input().split())
Time[0] += S
for i in range(1,N-1):
    Cnew, S, F = map(int,raw_input().split())
    Time[i] += S

    for j in range(i):
        if Time[j] > S:
            Time[j] = Time[j] + C
            Amari = (Time[j] - S) % F
            Time[j] = Time[j] + Amari
        else:
            Time[j] = S
    C = Cnew

for i in range(N-1):
    Time[i] += C
    print Time[i]
print Time[N-1]

Submission status: Wrong Answer

Solution code:
N = int(input())
clis = [];slis =[];flis = []
for i in range(N-1):
    c,s,f = map(int,input().split())
    clis.append(c);slis.append(s);flis.append(f)
for i in range(N):
    count=0
    for i2 in range(N-i-1):
        count = (count-slis[i2+i] if count >slis[i2+i] else 0)+slis[i2+i]+clis[i2+i]
    print(count)

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

#A, B = map(int,raw_input().split())
N = int(raw_input())

Time = [0 for i in range(N)]
C, S, F = map(int,raw_input().split())
Time[0] += S
for i in range(1,N-1):
    Cnew, S, F = map(int,raw_input().split())
    Time[i] += S

    for j in range(i):
        if Time[j] > S:
            Time[j] = Time[j] + C
            Amari = (Time[j] - S) % F
            Time[j] = Time[j] + Amari
        else:
            Time[j] = S
    C = Cnew

for i in range(N-1):
    Time[i] += C

print Time

Submission status: Wrong Answer

Solution code:
def solve():
    N = int(input())
    C = []
    S = []
    F = []
    for _ in range(N - 1):
        tmp_c, tmp_s, tmp_f = list(map(int, input().split(" ")))
        C.append(tmp_c)
        S.append(tmp_s)
        F.append(tmp_f)

    Answer = []
    for i in range(N - 2):
        current_time = C[i] + S[i]
        for j in range(i + 1, N - 1):
            if current_time >= S[j] and current_time % F[j] == 0:
                current_time += C[j]
            else:
                if current_time < S[j]:
                    current_time += C[j] + S[j] - current_time
                else:
                    i = 0
                    while (S[j] + F[j] * i) % current_time:
                        i += 1
                    current_time += C[j] + (S[j] + F[j] * i - current_time)

            if j == N - 2:
                Answer.append(current_time)

    Answer.append(S[-1] + C[-1])
    Answer.append(0)
    for ele in Answer:
        print(ele)


solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    t_C, t_S, t_F = map(int, input().split())
    C.append(t_C)
    S.append(t_S)
    F.append(t_F)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8
N = 0
C = []
S = []
F = []

# i駅での到着時間を指定すると、次の乗車時間が帰ってくる
def getNextTrain(i, time):
  t = S[i]
  while(1):
    if t >= time-1:
      break
    t += F[i]

  return t

# 入力部分
N = int(raw_input())
for i in range(N-1):
  c, s, f = map(int, raw_input().split())
  C.append(c)
  S.append(s)
  F.append(f)

# 処理部分
for k in range(N):
  arrive = 0
  for p in range(k, N-1): 
    # p駅から出発して
    arrive = getNextTrain(p, arrive)
    #print str(arrive) + '-> ' + str(p),
    arrive += C[p]
    #print '->' + str(arrive)
  print arrive

# 出力部分

Submission status: Wrong Answer

Solution code:
N = int(input())
clis = [];slis =[];flis = []
for i in range(N-1):
    c,s,f = map(int,input().split())
    clis.append(c);slis.append(s);flis.append(f)
for i in range(N):
    count=0
    for i2 in range(N-i-1):
        count = (count-slis[i2+i] if count >=slis[i2+i] else 0)+slis[i2+i]+clis[i2+i]
    print(count)

Submission status: Wrong Answer

Solution code:
ans = [0]
N = int(input())
train = [list(map(int,input().split())) for _ in range(N-1)]
P = 0
for i in range(N-2,-1,-1):
    s = train[i][0] + train[i][1]
    if i != (N-2):
        s += (s % Q) + P
    if s < ans[0]:
        s = ans[0]
    ans.insert(0,s)
    P += train[i][0]
    Q = train[i][2]
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N = int(input())						# 5

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

#print("C", C)
#print("S", S)
#print("F", F)

ans=[0]*(N+1)





#1から計算してみる
def nextArrive(n, iArrive, C,S,F):
	iAns = 0
	if iArrive <= S[n]:
		#⇒順次運行中
		iAns = S[n] + C[n]
	else:
		#⇒順次運行中
		iWait = iArrive % F[n]
		iAns = iArrive + iWait + C[n]
	
	return iAns

iArrive=0
for i in range(1, N):
	iArrive = S[i]
	for n in range(i, N):
		iArrive = nextArrive(n, iArrive, C,S,F)

	ans[i] = iArrive






#print(ans)

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

Submission status: Wrong Answer

Solution code:
ans = [0]
N = int(input())
train = [list(map(int,input().split())) for _ in range(N-1)]
P = 0
for i in range(N-2,-1,-1):
    s = train[i][0] + train[i][1]
    if i != (N-2):
        s += (s % train[i][2]) + P
    if s < ans[0]:
        s = ans[0]
    ans.insert(0,s)
    P += train[i][0]
for i in range(N):
    print(ans[i])

Submission status: Wrong Answer

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


def next_time(i, t):
    a = S[i]
    if t - a < 0:
        return a
    if t % F[i] == 0:
        return t
    b = (t - a + F[i] - 1) // F[i]
    # print(i, t, a, b, t + b * F[i])
    return t + b * F[i]


for i in range(N):
    time = 0
    for j in range(i, N - 1):
        time = next_time(j, time)
        time += C[j]

    print(time)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

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

  print(sum)

if n == 1:
  print(s[0] + s[1])
print(0)

Submission status: Wrong Answer

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

print(int('1'))

for i in range(N-1):
  _input = str(input().replace('\r','')).split(' ')
  print(_input)
  array.append((int(_input[0]), int(_input[1]), int(_input[2])))

for i in range(N-1):
  time = array[i][0] + array[i][1]
  for j in range(i+1, N-1):
    if array[j][1] > time:
      time = array[j][1]
    elif time % array[j][2] != 0:
      time = time - time % array[j][2] + array[j][2]
    time = time + array[j][0]
  print(time)

print(0)