結果

問題 No.1 道のショートカット
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2020-01-21 00:49:15
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,044 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 79,752 KB
最終ジャッジ日時 2023-09-22 13:40:31
合計ジャッジ時間 7,595 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,708 KB
testcase_01 AC 93 ms
71,292 KB
testcase_02 AC 100 ms
71,792 KB
testcase_03 AC 93 ms
71,740 KB
testcase_04 AC 93 ms
71,696 KB
testcase_05 AC 96 ms
71,732 KB
testcase_06 AC 98 ms
71,288 KB
testcase_07 AC 93 ms
71,632 KB
testcase_08 AC 151 ms
78,008 KB
testcase_09 AC 158 ms
77,560 KB
testcase_10 AC 131 ms
77,644 KB
testcase_11 AC 156 ms
77,744 KB
testcase_12 AC 217 ms
77,788 KB
testcase_13 AC 243 ms
77,880 KB
testcase_14 AC 112 ms
77,576 KB
testcase_15 RE -
testcase_16 WA -
testcase_17 AC 94 ms
71,416 KB
testcase_18 AC 122 ms
77,668 KB
testcase_19 AC 121 ms
77,668 KB
testcase_20 AC 126 ms
77,704 KB
testcase_21 WA -
testcase_22 AC 115 ms
77,420 KB
testcase_23 AC 172 ms
77,936 KB
testcase_24 AC 190 ms
78,060 KB
testcase_25 AC 127 ms
78,020 KB
testcase_26 AC 119 ms
77,492 KB
testcase_27 AC 182 ms
77,996 KB
testcase_28 AC 122 ms
77,416 KB
testcase_29 AC 125 ms
78,120 KB
testcase_30 AC 109 ms
77,748 KB
testcase_31 AC 112 ms
77,724 KB
testcase_32 AC 149 ms
77,772 KB
testcase_33 AC 132 ms
77,904 KB
testcase_34 AC 184 ms
78,092 KB
testcase_35 AC 107 ms
77,560 KB
testcase_36 AC 115 ms
77,892 KB
testcase_37 WA -
testcase_38 AC 104 ms
77,468 KB
testcase_39 WA -
testcase_40 AC 111 ms
77,776 KB
testcase_41 AC 99 ms
76,856 KB
testcase_42 AC 94 ms
71,444 KB
testcase_43 RE -
権限があれば一括ダウンロードができます

ソースコード

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]

    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