結果

問題 No.1 道のショートカット
ユーザー n_knuun_knuu
提出日時 2015-05-07 18:05:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 200 ms / 5,000 ms
コード長 697 bytes
コンパイル時間 1,906 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 83,080 KB
最終ジャッジ日時 2023-09-27 21:44:07
合計ジャッジ時間 10,307 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 173 ms
80,688 KB
testcase_01 AC 174 ms
80,776 KB
testcase_02 AC 178 ms
80,780 KB
testcase_03 AC 173 ms
80,808 KB
testcase_04 AC 172 ms
80,608 KB
testcase_05 AC 174 ms
80,820 KB
testcase_06 AC 172 ms
80,832 KB
testcase_07 AC 175 ms
80,720 KB
testcase_08 AC 198 ms
82,944 KB
testcase_09 AC 188 ms
82,564 KB
testcase_10 AC 192 ms
82,572 KB
testcase_11 AC 193 ms
82,780 KB
testcase_12 AC 199 ms
83,080 KB
testcase_13 AC 198 ms
82,952 KB
testcase_14 AC 191 ms
82,436 KB
testcase_15 AC 175 ms
81,088 KB
testcase_16 AC 193 ms
82,392 KB
testcase_17 AC 180 ms
82,088 KB
testcase_18 AC 189 ms
82,076 KB
testcase_19 AC 194 ms
82,420 KB
testcase_20 AC 197 ms
82,364 KB
testcase_21 AC 191 ms
82,148 KB
testcase_22 AC 188 ms
82,460 KB
testcase_23 AC 195 ms
82,604 KB
testcase_24 AC 200 ms
82,916 KB
testcase_25 AC 183 ms
82,272 KB
testcase_26 AC 186 ms
82,340 KB
testcase_27 AC 196 ms
82,820 KB
testcase_28 AC 185 ms
82,384 KB
testcase_29 AC 189 ms
82,932 KB
testcase_30 AC 179 ms
82,060 KB
testcase_31 AC 185 ms
82,348 KB
testcase_32 AC 199 ms
82,712 KB
testcase_33 AC 189 ms
82,724 KB
testcase_34 AC 192 ms
82,848 KB
testcase_35 AC 178 ms
82,300 KB
testcase_36 AC 184 ms
82,396 KB
testcase_37 AC 181 ms
82,308 KB
testcase_38 AC 184 ms
82,164 KB
testcase_39 AC 187 ms
82,376 KB
testcase_40 AC 180 ms
82,732 KB
testcase_41 AC 178 ms
82,076 KB
testcase_42 AC 172 ms
80,924 KB
testcase_43 AC 178 ms
82,132 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