結果

問題 No.1 道のショートカット
ユーザー n_knuun_knuu
提出日時 2015-05-07 17:59:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 5,000 ms
コード長 808 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 82,968 KB
最終ジャッジ日時 2023-09-27 21:43:51
合計ジャッジ時間 9,467 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
80,768 KB
testcase_01 AC 153 ms
80,644 KB
testcase_02 AC 156 ms
80,776 KB
testcase_03 AC 160 ms
80,648 KB
testcase_04 AC 153 ms
80,652 KB
testcase_05 AC 164 ms
80,684 KB
testcase_06 AC 158 ms
80,872 KB
testcase_07 AC 153 ms
81,320 KB
testcase_08 AC 190 ms
82,756 KB
testcase_09 AC 179 ms
82,240 KB
testcase_10 AC 174 ms
82,520 KB
testcase_11 AC 177 ms
82,928 KB
testcase_12 AC 188 ms
82,808 KB
testcase_13 AC 191 ms
82,560 KB
testcase_14 AC 170 ms
82,584 KB
testcase_15 AC 155 ms
81,352 KB
testcase_16 AC 174 ms
82,560 KB
testcase_17 AC 162 ms
82,200 KB
testcase_18 AC 172 ms
82,256 KB
testcase_19 AC 177 ms
82,340 KB
testcase_20 AC 178 ms
82,404 KB
testcase_21 AC 171 ms
82,224 KB
testcase_22 AC 166 ms
82,420 KB
testcase_23 AC 171 ms
82,920 KB
testcase_24 AC 187 ms
82,968 KB
testcase_25 AC 173 ms
82,060 KB
testcase_26 AC 175 ms
82,464 KB
testcase_27 AC 183 ms
82,836 KB
testcase_28 AC 168 ms
82,036 KB
testcase_29 AC 168 ms
82,856 KB
testcase_30 AC 165 ms
82,044 KB
testcase_31 AC 167 ms
82,396 KB
testcase_32 AC 184 ms
82,304 KB
testcase_33 AC 173 ms
82,380 KB
testcase_34 AC 184 ms
82,952 KB
testcase_35 AC 164 ms
82,296 KB
testcase_36 AC 167 ms
82,552 KB
testcase_37 AC 161 ms
82,296 KB
testcase_38 AC 170 ms
82,160 KB
testcase_39 AC 173 ms
82,332 KB
testcase_40 AC 184 ms
82,236 KB
testcase_41 AC 165 ms
82,000 KB
testcase_42 AC 153 ms
80,620 KB
testcase_43 AC 155 ms
82,236 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