Submission #50193904


Source Code Expand

#ABC340_20240210_D
INF=10**18
import heapq

N=int(input())
g=[[] for _ in range(N+1)]
for i in range(1,N):
    a,b,x=map(int,input().split())
    g[i].append((i+1,a))
    g[i].append((x,b))
d=[INF]*(N+1)
d[1]=0
q=[(0,1)]
while(q):
    c,v=heapq.heappop(q)
    if(d[v]<c):
        continue
    for u,w in g[v]:
        if(d[u]>c+w):
            d[u]=c+w
            heapq.heappush(q,(d[u],u))
if(d[N]<INF):
    print(d[N])
else:
    print(-1)

Submission Info

Submission Time
Task D - Super Takahashi Bros.
User Konini
Language Python (PyPy 3.10-v7.3.12)
Score 425
Code Size 467 Byte
Status AC
Exec Time 388 ms
Memory 123592 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All min.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
min.txt AC 58 ms 76964 KiB
random_01.txt AC 388 ms 123048 KiB
random_02.txt AC 237 ms 103416 KiB
random_03.txt AC 383 ms 123592 KiB
random_04.txt AC 375 ms 120728 KiB
random_05.txt AC 175 ms 115536 KiB
random_06.txt AC 171 ms 107096 KiB
random_07.txt AC 228 ms 117252 KiB
random_08.txt AC 120 ms 86320 KiB
random_09.txt AC 255 ms 117452 KiB
random_10.txt AC 213 ms 106056 KiB
random_11.txt AC 272 ms 118408 KiB
random_12.txt AC 149 ms 89788 KiB
random_13.txt AC 202 ms 117376 KiB
random_14.txt AC 200 ms 116692 KiB
random_15.txt AC 60 ms 76744 KiB
sample_01.txt AC 57 ms 76392 KiB
sample_02.txt AC 58 ms 76540 KiB
sample_03.txt AC 57 ms 76644 KiB