結果

問題 No.1 道のショートカット
ユーザー n_knuun_knuu
提出日時 2015-05-07 18:05:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 147 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 376 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 9,676 KB
最終ジャッジ日時 2023-09-27 21:43:16
合計ジャッジ時間 3,595 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,084 KB
testcase_01 AC 20 ms
8,932 KB
testcase_02 AC 20 ms
8,948 KB
testcase_03 AC 20 ms
9,120 KB
testcase_04 AC 20 ms
8,948 KB
testcase_05 AC 22 ms
9,144 KB
testcase_06 AC 20 ms
8,976 KB
testcase_07 AC 20 ms
9,060 KB
testcase_08 AC 107 ms
9,408 KB
testcase_09 AC 65 ms
9,308 KB
testcase_10 AC 47 ms
9,316 KB
testcase_11 AC 56 ms
9,096 KB
testcase_12 AC 147 ms
9,676 KB
testcase_13 AC 146 ms
9,600 KB
testcase_14 AC 28 ms
9,084 KB
testcase_15 AC 21 ms
9,104 KB
testcase_16 AC 36 ms
9,152 KB
testcase_17 AC 20 ms
9,008 KB
testcase_18 AC 26 ms
9,116 KB
testcase_19 AC 33 ms
9,044 KB
testcase_20 AC 37 ms
9,188 KB
testcase_21 AC 39 ms
9,152 KB
testcase_22 AC 30 ms
8,964 KB
testcase_23 AC 84 ms
9,096 KB
testcase_24 AC 108 ms
9,144 KB
testcase_25 AC 52 ms
9,208 KB
testcase_26 AC 39 ms
9,036 KB
testcase_27 AC 84 ms
9,324 KB
testcase_28 AC 21 ms
9,096 KB
testcase_29 AC 34 ms
9,176 KB
testcase_30 AC 25 ms
8,996 KB
testcase_31 AC 31 ms
9,152 KB
testcase_32 AC 83 ms
9,444 KB
testcase_33 AC 64 ms
9,248 KB
testcase_34 AC 102 ms
9,352 KB
testcase_35 AC 25 ms
9,208 KB
testcase_36 AC 35 ms
9,220 KB
testcase_37 AC 24 ms
9,040 KB
testcase_38 AC 23 ms
9,012 KB
testcase_39 AC 36 ms
9,248 KB
testcase_40 AC 25 ms
9,208 KB
testcase_41 AC 21 ms
9,144 KB
testcase_42 AC 20 ms
9,088 KB
testcase_43 AC 23 ms
9,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from queue import PriorityQueue as PQueue
N = int(input())
C = int(input())
V = int(input())
S = list(map(lambda x: int(x)-1, input().split()))
T = list(map(lambda x: int(x)-1, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
E = [[] for _ in range(N)]
for f, t, cost, time in zip(S, T, Y, M):
    E[t].append((f, cost, time))
INF = 10**7
dp = [[INF] * (C+1) for _ in range(N)]
for i in range(C+1):
    dp[0][i] = 0
for t in range(N):
    for j in range(C+1):
        for f, cost, time in E[t]:
            if j >= cost and dp[t][j] > dp[f][j-cost] + time:
                dp[t][j] = dp[f][j-cost] + time
print(min(dp[N-1]) if min(dp[N-1]) != INF else -1)
0