結果

問題 No.1 道のショートカット
ユーザー kohei2019kohei2019
提出日時 2021-01-11 20:41:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 235 ms / 5,000 ms
コード長 729 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-05-01 06:55:54
合計ジャッジ時間 4,898 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 31 ms
11,008 KB
testcase_05 AC 31 ms
11,008 KB
testcase_06 AC 31 ms
10,880 KB
testcase_07 AC 32 ms
11,008 KB
testcase_08 AC 180 ms
11,136 KB
testcase_09 AC 108 ms
11,136 KB
testcase_10 AC 74 ms
11,008 KB
testcase_11 AC 99 ms
11,008 KB
testcase_12 AC 235 ms
11,392 KB
testcase_13 AC 228 ms
11,264 KB
testcase_14 AC 42 ms
10,880 KB
testcase_15 AC 31 ms
10,880 KB
testcase_16 AC 56 ms
10,880 KB
testcase_17 AC 31 ms
10,880 KB
testcase_18 AC 40 ms
10,880 KB
testcase_19 AC 49 ms
11,008 KB
testcase_20 AC 54 ms
11,008 KB
testcase_21 AC 63 ms
10,880 KB
testcase_22 AC 46 ms
10,880 KB
testcase_23 AC 164 ms
11,008 KB
testcase_24 AC 185 ms
11,008 KB
testcase_25 AC 81 ms
10,880 KB
testcase_26 AC 65 ms
10,880 KB
testcase_27 AC 143 ms
11,136 KB
testcase_28 AC 33 ms
10,880 KB
testcase_29 AC 55 ms
11,136 KB
testcase_30 AC 35 ms
10,880 KB
testcase_31 AC 49 ms
11,008 KB
testcase_32 AC 131 ms
11,008 KB
testcase_33 AC 99 ms
11,008 KB
testcase_34 AC 159 ms
11,008 KB
testcase_35 AC 36 ms
11,008 KB
testcase_36 AC 53 ms
11,008 KB
testcase_37 AC 36 ms
10,880 KB
testcase_38 AC 35 ms
10,880 KB
testcase_39 AC 52 ms
11,008 KB
testcase_40 AC 36 ms
11,008 KB
testcase_41 AC 33 ms
11,008 KB
testcase_42 AC 31 ms
10,880 KB
testcase_43 AC 31 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#dp[j][k] = 町jに所持金k円で行く最短時間
N = int(input())
C = int(input())
V = int(input())
lsS = list(map(int,input().split()))
lsT = list(map(int,input().split()))
lsY = list(map(int,input().split()))
lsM = list(map(int,input().split()))
lsedge = []
for i in range(V):
    lsedge.append((lsS[i],lsT[i],lsY[i],lsM[i]))
lsedge.sort()
dp = [[float('INF')]*(C+1) for i in range(N+1) ]
dp[1][C] = 0
for i in range(1,V+1):
    from1 = lsedge[i-1][0]
    to = lsedge[i-1][1]
    cost = lsedge[i-1][2]
    time = lsedge[i-1][3]
    for k in range(C+1):
        if k - cost >= 0:
            dp[to][k-cost] = min(dp[to][k-cost],dp[from1][k]+time)
if min(dp[N]) == float('INF'):
    print(-1)
else:
    print(min(dp[N]))
0