結果

問題 No.1 道のショートカット
ユーザー Yuta123456Yuta123456
提出日時 2020-05-21 19:51:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 827 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 8,896 KB
最終ジャッジ日時 2023-09-27 22:29:03
合計ジャッジ時間 2,709 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,880 KB
testcase_01 AC 15 ms
8,204 KB
testcase_02 AC 16 ms
7,896 KB
testcase_03 AC 14 ms
8,200 KB
testcase_04 AC 14 ms
8,228 KB
testcase_05 AC 14 ms
8,204 KB
testcase_06 AC 14 ms
8,228 KB
testcase_07 AC 15 ms
7,836 KB
testcase_08 AC 26 ms
8,468 KB
testcase_09 AC 18 ms
8,324 KB
testcase_10 AC 25 ms
8,380 KB
testcase_11 AC 48 ms
8,320 KB
testcase_12 AC 77 ms
8,828 KB
testcase_13 AC 71 ms
8,896 KB
testcase_14 AC 16 ms
8,252 KB
testcase_15 AC 16 ms
8,264 KB
testcase_16 AC 16 ms
8,344 KB
testcase_17 AC 16 ms
8,308 KB
testcase_18 AC 16 ms
8,308 KB
testcase_19 AC 16 ms
8,224 KB
testcase_20 AC 20 ms
8,440 KB
testcase_21 AC 16 ms
8,436 KB
testcase_22 AC 16 ms
8,264 KB
testcase_23 AC 110 ms
8,360 KB
testcase_24 AC 106 ms
8,296 KB
testcase_25 AC 29 ms
8,316 KB
testcase_26 AC 21 ms
8,260 KB
testcase_27 AC 82 ms
8,424 KB
testcase_28 AC 15 ms
8,212 KB
testcase_29 AC 28 ms
8,236 KB
testcase_30 AC 16 ms
8,400 KB
testcase_31 AC 25 ms
8,236 KB
testcase_32 AC 32 ms
8,656 KB
testcase_33 AC 22 ms
8,320 KB
testcase_34 AC 85 ms
8,488 KB
testcase_35 AC 16 ms
8,232 KB
testcase_36 AC 19 ms
8,248 KB
testcase_37 AC 16 ms
8,264 KB
testcase_38 AC 15 ms
7,844 KB
testcase_39 AC 17 ms
8,324 KB
testcase_40 AC 16 ms
8,324 KB
testcase_41 AC 16 ms
8,364 KB
testcase_42 AC 14 ms
8,352 KB
testcase_43 AC 16 ms
8,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()))
adjacent_list = [[] for i in range(n+1)]
for i in range(v):
    adjacent_list[s[i]].append([t[i],y[i],m[i]])
dp = [[10**9 for i in range(c+1)] for j in range(n+1)]
#dp[i][j] := i番目の街に行き、j円使った時の最短時間
dp[0][0] = 0
dp[1][0] = 0
for i in range(1,n+1):
    for j in range(c+1):
        if dp[i][j] != 10**9:
            for next_node,cost, time in adjacent_list[i]:
                if j + cost <= c:
                    dp[next_node][j+cost] = min(dp[next_node][j+cost], dp[i][j] + time)
ans = 10**9
for i in range(c+1):
    ans = min(ans, dp[-1][i])
if ans == 10**9:
    print(-1)
else:
    print(ans)
0