結果

問題 No.1 道のショートカット
ユーザー titiatitia
提出日時 2021-11-01 14:19:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 709 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-04-18 09:40:17
合計ジャッジ時間 5,533 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
10,880 KB
testcase_01 AC 35 ms
11,008 KB
testcase_02 AC 33 ms
10,880 KB
testcase_03 AC 32 ms
11,008 KB
testcase_04 AC 32 ms
10,880 KB
testcase_05 AC 32 ms
11,008 KB
testcase_06 AC 33 ms
11,008 KB
testcase_07 AC 32 ms
10,880 KB
testcase_08 AC 190 ms
11,904 KB
testcase_09 AC 157 ms
12,160 KB
testcase_10 AC 90 ms
11,520 KB
testcase_11 AC 119 ms
11,520 KB
testcase_12 AC 361 ms
13,056 KB
testcase_13 AC 360 ms
12,928 KB
testcase_14 AC 48 ms
11,008 KB
testcase_15 AC 31 ms
11,008 KB
testcase_16 WA -
testcase_17 AC 32 ms
11,008 KB
testcase_18 AC 47 ms
11,136 KB
testcase_19 AC 73 ms
11,392 KB
testcase_20 AC 71 ms
11,136 KB
testcase_21 WA -
testcase_22 AC 62 ms
11,264 KB
testcase_23 AC 177 ms
11,648 KB
testcase_24 AC 201 ms
11,776 KB
testcase_25 AC 107 ms
11,776 KB
testcase_26 AC 81 ms
11,392 KB
testcase_27 AC 176 ms
11,904 KB
testcase_28 AC 36 ms
10,880 KB
testcase_29 AC 60 ms
11,136 KB
testcase_30 AC 38 ms
11,008 KB
testcase_31 AC 55 ms
11,008 KB
testcase_32 AC 164 ms
11,776 KB
testcase_33 AC 119 ms
11,520 KB
testcase_34 AC 208 ms
11,776 KB
testcase_35 AC 36 ms
11,136 KB
testcase_36 AC 57 ms
11,264 KB
testcase_37 WA -
testcase_38 AC 32 ms
11,008 KB
testcase_39 WA -
testcase_40 AC 38 ms
11,008 KB
testcase_41 AC 33 ms
11,008 KB
testcase_42 AC 32 ms
10,880 KB
testcase_43 AC 32 ms
10,880 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()))

E=[[] for i in range(N+1)]

for i in range(V):
    E[S[i]].append((T[i],Y[i],M[i]))
    E[T[i]].append((S[i],Y[i],M[i]))

DP=[[1<<30]*(C+1) for i in range(N+1)]

DP[1][C]=0

Q=[(0,1,C)]

while Q:
    now,town,money=heapq.heappop(Q)
    if now>DP[town][money]:
        continue

    for to,y,m in E[town]:
        if money-y>=0 and DP[to][money-y]>now+m:
            DP[to][money-y]=now+m
            heapq.heappush(Q,(now+m,to,money-y))

MIN=min(DP[N])

if MIN==1<<30:
    print(-1)
else:
    print(MIN)
            
0