結果

問題 No.1 道のショートカット
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-04-05 10:11:16
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 162 ms / 5,000 ms
コード長 609 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 79,240 KB
最終ジャッジ日時 2023-08-28 22:19:01
合計ジャッジ時間 6,419 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,664 KB
testcase_01 AC 76 ms
71,332 KB
testcase_02 AC 77 ms
71,680 KB
testcase_03 AC 78 ms
71,448 KB
testcase_04 AC 79 ms
71,640 KB
testcase_05 AC 78 ms
71,284 KB
testcase_06 AC 79 ms
71,472 KB
testcase_07 AC 78 ms
71,700 KB
testcase_08 AC 122 ms
78,436 KB
testcase_09 AC 99 ms
76,892 KB
testcase_10 AC 120 ms
78,348 KB
testcase_11 AC 133 ms
78,640 KB
testcase_12 AC 162 ms
79,240 KB
testcase_13 AC 153 ms
78,716 KB
testcase_14 AC 78 ms
71,392 KB
testcase_15 AC 77 ms
71,348 KB
testcase_16 AC 93 ms
76,772 KB
testcase_17 AC 78 ms
71,460 KB
testcase_18 AC 77 ms
71,436 KB
testcase_19 AC 78 ms
71,508 KB
testcase_20 AC 120 ms
77,828 KB
testcase_21 AC 90 ms
76,544 KB
testcase_22 AC 78 ms
71,616 KB
testcase_23 AC 144 ms
78,816 KB
testcase_24 AC 151 ms
79,104 KB
testcase_25 AC 129 ms
78,164 KB
testcase_26 AC 114 ms
77,788 KB
testcase_27 AC 154 ms
78,984 KB
testcase_28 AC 77 ms
71,524 KB
testcase_29 AC 112 ms
78,172 KB
testcase_30 AC 87 ms
76,516 KB
testcase_31 AC 95 ms
76,556 KB
testcase_32 AC 122 ms
78,296 KB
testcase_33 AC 117 ms
78,044 KB
testcase_34 AC 146 ms
78,760 KB
testcase_35 AC 81 ms
75,932 KB
testcase_36 AC 109 ms
77,948 KB
testcase_37 AC 85 ms
76,612 KB
testcase_38 AC 77 ms
71,328 KB
testcase_39 AC 78 ms
71,528 KB
testcase_40 AC 84 ms
76,588 KB
testcase_41 AC 77 ms
71,496 KB
testcase_42 AC 78 ms
71,504 KB
testcase_43 AC 79 ms
71,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappop, heappush
n = int(input())
c = int(input())
v = int(input())
L = [list(map(int,input().split())) for i in range(4)]

e = [[] for i in range(n)]
for s,t,y,m in zip(L[0],L[1],L[2],L[3]):
    e[s-1].append((t-1,y,m))


inf = 10**10
dis = [[inf]*(c+1) for i in range(n)]
dis[0][c] = 0
q = [(0,0,c)]
while q:
    time,now,d = heappop(q)
    if time > dis[now][d]:
        continue
    for nex,y,m in e[now]:
        if d >= y and dis[nex][d-y] > time+m:
            dis[nex][d-y] = time+m
            heappush(q, (time+m,nex,d-y))
ans = min(dis[-1])
if ans == inf:
    ans = -1
print(ans)
0