結果

問題 No.1 道のショートカット
ユーザー syunsuke1024syunsuke1024
提出日時 2020-05-05 10:53:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 90,020 KB
最終ジャッジ日時 2023-09-22 13:43:21
合計ジャッジ時間 7,280 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,368 KB
testcase_01 AC 76 ms
71,540 KB
testcase_02 AC 77 ms
71,372 KB
testcase_03 AC 77 ms
71,376 KB
testcase_04 AC 80 ms
71,348 KB
testcase_05 AC 76 ms
71,596 KB
testcase_06 AC 77 ms
71,268 KB
testcase_07 AC 76 ms
71,384 KB
testcase_08 AC 142 ms
78,292 KB
testcase_09 AC 97 ms
76,768 KB
testcase_10 AC 143 ms
79,120 KB
testcase_11 AC 166 ms
79,432 KB
testcase_12 AC 200 ms
80,588 KB
testcase_13 AC 175 ms
79,580 KB
testcase_14 AC 78 ms
75,288 KB
testcase_15 AC 77 ms
75,204 KB
testcase_16 AC 82 ms
76,296 KB
testcase_17 AC 76 ms
75,008 KB
testcase_18 AC 78 ms
75,128 KB
testcase_19 AC 81 ms
75,444 KB
testcase_20 AC 137 ms
78,488 KB
testcase_21 AC 97 ms
76,464 KB
testcase_22 AC 82 ms
75,748 KB
testcase_23 AC 438 ms
90,020 KB
testcase_24 AC 396 ms
87,816 KB
testcase_25 AC 156 ms
78,868 KB
testcase_26 AC 130 ms
78,092 KB
testcase_27 AC 269 ms
83,520 KB
testcase_28 AC 77 ms
75,128 KB
testcase_29 AC 132 ms
78,376 KB
testcase_30 AC 99 ms
77,012 KB
testcase_31 AC 136 ms
78,588 KB
testcase_32 AC 148 ms
79,020 KB
testcase_33 AC 125 ms
78,000 KB
testcase_34 AC 173 ms
79,656 KB
testcase_35 AC 92 ms
76,596 KB
testcase_36 AC 118 ms
78,408 KB
testcase_37 AC 93 ms
76,692 KB
testcase_38 AC 79 ms
75,120 KB
testcase_39 AC 80 ms
75,496 KB
testcase_40 WA -
testcase_41 AC 75 ms
71,232 KB
testcase_42 AC 77 ms
71,620 KB
testcase_43 AC 78 ms
75,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
C=int(input())
V=int(input())

S=list(map(int,input().split()))
T=list(map(int,input().split()))
Cost=list(map(int,input().split()))
Time=list(map(int,input().split()))

L=[[]for i in range(N+1)]
for i in range(V):
    L[S[i]].append([Time[i],Cost[i],T[i]])

DP=[[10**9 for i in range(C+1)]for j in range(N+1)]

DP[1][0]=0
#print(DP)

import heapq
Q=[]
for time,cost,t in L[1]:
    if cost<=C:
        Q.append((time,cost,t))

heapq.heapify(Q)
for i in range(10**7):
    if len(Q)==0:
        break
    time,cost,t=heapq.heappop(Q)
    if DP[t][cost]==10**9:
        DP[t][cost]=time
        for fortime,forcost,fort in L[t]:
            if cost+forcost<=C and DP[t][cost+forcost]==10**9:
                heapq.heappush(Q,(time+fortime,cost+forcost,fort))
if min(DP[-1])==10**9:
    print(-1)
else:
    print(min(DP[-1]))
0