Submission #1927692


Source Code Expand

Copy
N=int(input())
C,S,F=[0]*(N-1),[0]*(N-1),[0]*(N-1)
for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())
for i in range(N-1): #一周につき一つの駅([0]..[N-2])から[N-1]までの計算
    arrivalTime=S[i]+C[i]#最初発車駅の次の駅に着く時間
    for j in range(i+1,N-1):
        leaveTime=S[j]#現在考慮中の駅から初めて発車する時間
        if arrivalTime <leaveTime:
            pass
        elif arrivalTime % F[j]==0:
            leaveTime=arrivalTime
        else:
            leaveTime=arrivalTime+F[j]- arrivalTime % F[j]
        '''
        while arrivalTime > leaveTime:
            leaveTime+=F[j]
        '''
        arrivalTime=leaveTime+C[j]
    print(arrivalTime)
print(0)#[N-1]駅

Submission Info

Submission Time
Task C - Special Trains
User Yodadayo
Language Python (3.4.3)
Score 300
Code Size 761 Byte
Status AC
Exec Time 107 ms
Memory 3064 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt AC 95 ms 3064 KB
02.txt AC 96 ms 3064 KB
03.txt AC 103 ms 3064 KB
04.txt AC 97 ms 3064 KB
05.txt AC 104 ms 3064 KB
06.txt AC 71 ms 3064 KB
07.txt AC 96 ms 3064 KB
08.txt AC 107 ms 3064 KB
09.txt AC 16 ms 3064 KB
10.txt AC 33 ms 3064 KB
11.txt AC 82 ms 3064 KB
12.txt AC 22 ms 3064 KB
sample_01.txt AC 17 ms 3064 KB
sample_02.txt AC 17 ms 3064 KB
sample_03.txt AC 17 ms 3064 KB