結果

問題 No.1 道のショートカット
ユーザー HydruHydru
提出日時 2021-11-11 20:38:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 413 ms
コンパイル使用メモリ 82,568 KB
実行使用メモリ 67,236 KB
最終ジャッジ日時 2024-05-02 22:21:49
合計ジャッジ時間 3,845 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,812 KB
testcase_01 AC 40 ms
53,080 KB
testcase_02 AC 40 ms
53,800 KB
testcase_03 AC 41 ms
53,204 KB
testcase_04 AC 39 ms
53,864 KB
testcase_05 AC 39 ms
53,568 KB
testcase_06 AC 39 ms
52,776 KB
testcase_07 AC 40 ms
53,356 KB
testcase_08 AC 46 ms
61,532 KB
testcase_09 AC 43 ms
59,648 KB
testcase_10 AC 43 ms
60,480 KB
testcase_11 AC 46 ms
61,544 KB
testcase_12 AC 46 ms
61,620 KB
testcase_13 AC 47 ms
62,196 KB
testcase_14 AC 39 ms
52,836 KB
testcase_15 AC 39 ms
53,112 KB
testcase_16 AC 44 ms
59,532 KB
testcase_17 AC 40 ms
52,860 KB
testcase_18 AC 41 ms
52,936 KB
testcase_19 AC 41 ms
53,232 KB
testcase_20 AC 44 ms
59,700 KB
testcase_21 AC 41 ms
53,140 KB
testcase_22 AC 40 ms
53,040 KB
testcase_23 AC 59 ms
67,236 KB
testcase_24 AC 47 ms
61,592 KB
testcase_25 AC 42 ms
58,748 KB
testcase_26 AC 41 ms
54,204 KB
testcase_27 AC 49 ms
61,568 KB
testcase_28 AC 41 ms
53,376 KB
testcase_29 AC 47 ms
62,096 KB
testcase_30 AC 44 ms
58,964 KB
testcase_31 AC 46 ms
60,108 KB
testcase_32 AC 45 ms
60,108 KB
testcase_33 AC 44 ms
59,792 KB
testcase_34 AC 47 ms
61,180 KB
testcase_35 AC 49 ms
60,928 KB
testcase_36 AC 44 ms
59,436 KB
testcase_37 AC 44 ms
59,600 KB
testcase_38 AC 40 ms
53,152 KB
testcase_39 AC 40 ms
53,028 KB
testcase_40 AC 44 ms
60,336 KB
testcase_41 AC 40 ms
53,424 KB
testcase_42 AC 39 ms
53,068 KB
testcase_43 AC 39 ms
53,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
N = int(input())
C = int(input())
V = int(input())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
Y = list(map(int,input().split()))
M = list(map(int,input().split()))

G=[[] for _ in range(N)]
for i in range(V):
    G[S[i]-1].append((M[i],Y[i],T[i]-1))

hq=[(0,0,0,[False]*N)]
heapq.heapify(hq)

while(hq):
    t,c,v,A=heapq.heappop(hq)
    vis=A.copy()
    vis[v]=True
    if v==N-1:
        print(t)
        exit()
    for m,y,u in G[v]:
        if c+y<=C and vis[u]==0:
            heapq.heappush(hq,(t+m,c+y,u,vis))
print(-1)
0