結果

問題 No.1 道のショートカット
ユーザー nsd_fbnsd_fb
提出日時 2015-02-19 03:09:38
言語 Python2
(2.7.18)
結果
AC  
実行時間 187 ms / 5,000 ms
コード長 643 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 6,540 KB
実行使用メモリ 6,660 KB
最終ジャッジ日時 2023-09-27 21:39:17
合計ジャッジ時間 3,829 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
6,000 KB
testcase_01 AC 12 ms
6,116 KB
testcase_02 AC 11 ms
6,060 KB
testcase_03 AC 12 ms
6,100 KB
testcase_04 AC 11 ms
5,972 KB
testcase_05 AC 12 ms
6,112 KB
testcase_06 AC 11 ms
6,056 KB
testcase_07 AC 12 ms
6,148 KB
testcase_08 AC 147 ms
6,320 KB
testcase_09 AC 81 ms
6,352 KB
testcase_10 AC 50 ms
6,220 KB
testcase_11 AC 69 ms
6,388 KB
testcase_12 AC 187 ms
6,660 KB
testcase_13 AC 183 ms
6,508 KB
testcase_14 AC 22 ms
6,040 KB
testcase_15 AC 13 ms
6,248 KB
testcase_16 AC 36 ms
6,260 KB
testcase_17 AC 12 ms
6,100 KB
testcase_18 AC 20 ms
6,056 KB
testcase_19 AC 28 ms
6,100 KB
testcase_20 AC 32 ms
6,268 KB
testcase_21 AC 37 ms
6,268 KB
testcase_22 AC 25 ms
6,072 KB
testcase_23 AC 120 ms
6,224 KB
testcase_24 AC 139 ms
6,244 KB
testcase_25 AC 52 ms
6,180 KB
testcase_26 AC 41 ms
6,132 KB
testcase_27 AC 106 ms
6,224 KB
testcase_28 AC 13 ms
6,004 KB
testcase_29 AC 34 ms
6,396 KB
testcase_30 AC 17 ms
6,156 KB
testcase_31 AC 28 ms
6,124 KB
testcase_32 AC 102 ms
6,356 KB
testcase_33 AC 74 ms
6,352 KB
testcase_34 AC 124 ms
6,268 KB
testcase_35 AC 16 ms
6,244 KB
testcase_36 AC 32 ms
6,296 KB
testcase_37 AC 16 ms
6,132 KB
testcase_38 AC 16 ms
6,240 KB
testcase_39 AC 32 ms
6,120 KB
testcase_40 AC 17 ms
6,096 KB
testcase_41 AC 14 ms
6,024 KB
testcase_42 AC 12 ms
6,000 KB
testcase_43 AC 13 ms
6,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
C = input()
M = input()

S = map(int, raw_input().split())
T = map(int, raw_input().split())
D = map(int, raw_input().split())
M = map(int, raw_input().split())

E = [[] for _ in xrange(N)]

for s, t, d, m in zip(S, T, D, M):
    E[s - 1].append((t - 1, d, m))

dist = [[float("inf")] * (C + 1) for _ in xrange(N)]
dist[0][0] = 0

for v in xrange(N):
    for c in xrange(C + 1):
        for to, cost, time in E[v]:
            next_cost = c + cost
            if next_cost <= C:
                dist[to][next_cost] = min(dist[to][next_cost], dist[v][c] + time)

ans = min(dist[N - 1])
print ans if ans != float("inf") else -1
    
0