結果

問題 No.1 道のショートカット
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-01-21 00:52:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 86,916 KB
実行使用メモリ 78,360 KB
最終ジャッジ日時 2023-09-22 13:40:22
合計ジャッジ時間 7,293 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,752 KB
testcase_01 AC 92 ms
71,448 KB
testcase_02 AC 93 ms
71,828 KB
testcase_03 AC 95 ms
71,748 KB
testcase_04 AC 91 ms
71,484 KB
testcase_05 AC 91 ms
71,752 KB
testcase_06 AC 94 ms
71,656 KB
testcase_07 AC 92 ms
71,748 KB
testcase_08 AC 146 ms
78,132 KB
testcase_09 AC 160 ms
78,112 KB
testcase_10 AC 125 ms
78,144 KB
testcase_11 AC 151 ms
78,100 KB
testcase_12 AC 213 ms
78,308 KB
testcase_13 AC 236 ms
78,096 KB
testcase_14 AC 110 ms
77,584 KB
testcase_15 AC 91 ms
71,632 KB
testcase_16 WA -
testcase_17 AC 90 ms
71,752 KB
testcase_18 AC 117 ms
78,360 KB
testcase_19 AC 120 ms
77,876 KB
testcase_20 AC 125 ms
78,168 KB
testcase_21 WA -
testcase_22 AC 116 ms
77,416 KB
testcase_23 AC 168 ms
78,120 KB
testcase_24 AC 189 ms
78,100 KB
testcase_25 AC 125 ms
78,140 KB
testcase_26 AC 117 ms
77,692 KB
testcase_27 AC 182 ms
78,260 KB
testcase_28 AC 117 ms
77,884 KB
testcase_29 AC 123 ms
78,280 KB
testcase_30 AC 110 ms
77,856 KB
testcase_31 AC 114 ms
77,788 KB
testcase_32 AC 142 ms
78,000 KB
testcase_33 AC 128 ms
78,132 KB
testcase_34 AC 189 ms
77,948 KB
testcase_35 AC 106 ms
77,472 KB
testcase_36 AC 114 ms
78,076 KB
testcase_37 WA -
testcase_38 AC 100 ms
77,676 KB
testcase_39 WA -
testcase_40 AC 113 ms
78,080 KB
testcase_41 AC 104 ms
76,616 KB
testcase_42 AC 96 ms
71,856 KB
testcase_43 AC 98 ms
71,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

Sori = list(map(int,input().split()))
Tori = list(map(int,input().split()))
Yori = list(map(int,input().split()))
Mori = list(map(int,input().split()))

dic = {}

for i in range(V):

    s = Sori[i]-1
    t = Tori[i]-1

    y = Yori[i]
    m = Mori[i]

    if s not in dic:
        dic[s] = []
    if t not in dic:
        dic[t] = []

    dic[s].append([t,y,m])
    dic[t].append([s,y,m])


lis = [[float("inf")] * (C+1) for i in range(N) ]
lis[0][0] = 0

q = deque([])
q.append([0,0])

while len(q) > 0:

    now = q.popleft()
    np = now[0]
    nc = now[1]

    if np not in dic:
        continue

    for i in dic[np]:

        nexp = i[0]
        nexc = i[1]
        dis = i[2]

        if nc + nexc <= C:

            if lis[nexp][nc+nexc] > lis[np][nc] + dis:
                lis[nexp][nc+nexc] = lis[np][nc] + dis
                q.append([nexp,nc+nexc])

ans = float("inf")

for i in range(C+1):

    ans = min(ans , lis[-1][i])

if ans == float("inf"):
    print (-1)
else:
    print (ans)
0