結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
9,072 KB
testcase_01 AC 21 ms
8,988 KB
testcase_02 AC 21 ms
9,060 KB
testcase_03 AC 21 ms
8,992 KB
testcase_04 AC 21 ms
9,144 KB
testcase_05 AC 21 ms
9,156 KB
testcase_06 AC 21 ms
8,948 KB
testcase_07 AC 22 ms
9,144 KB
testcase_08 AC 205 ms
9,352 KB
testcase_09 AC 114 ms
9,296 KB
testcase_10 AC 75 ms
9,332 KB
testcase_11 AC 92 ms
9,168 KB
testcase_12 AC 246 ms
9,660 KB
testcase_13 AC 243 ms
9,616 KB
testcase_14 AC 38 ms
9,192 KB
testcase_15 AC 23 ms
9,216 KB
testcase_16 AC 54 ms
9,144 KB
testcase_17 AC 23 ms
9,164 KB
testcase_18 AC 32 ms
9,044 KB
testcase_19 AC 41 ms
9,004 KB
testcase_20 AC 48 ms
9,148 KB
testcase_21 AC 53 ms
9,140 KB
testcase_22 AC 37 ms
9,116 KB
testcase_23 AC 156 ms
9,184 KB
testcase_24 AC 177 ms
9,292 KB
testcase_25 AC 73 ms
9,052 KB
testcase_26 AC 55 ms
9,136 KB
testcase_27 AC 139 ms
9,168 KB
testcase_28 AC 24 ms
8,956 KB
testcase_29 AC 46 ms
9,160 KB
testcase_30 AC 27 ms
8,992 KB
testcase_31 AC 42 ms
9,152 KB
testcase_32 AC 147 ms
9,500 KB
testcase_33 AC 100 ms
9,276 KB
testcase_34 AC 169 ms
9,288 KB
testcase_35 AC 25 ms
9,164 KB
testcase_36 AC 46 ms
9,172 KB
testcase_37 AC 26 ms
9,084 KB
testcase_38 AC 26 ms
9,168 KB
testcase_39 AC 47 ms
9,312 KB
testcase_40 AC 27 ms
9,076 KB
testcase_41 AC 22 ms
9,104 KB
testcase_42 AC 20 ms
8,984 KB
testcase_43 AC 21 ms
9,084 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
while True:
    flag = False
    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
                    flag = True
    if not flag:
        break
print(min(dp[N-1]) if min(dp[N-1]) != INF else -1)
0