結果

問題 No.1 道のショートカット
ユーザー roarisroaris
提出日時 2019-08-22 14:22:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 737 bytes
コンパイル時間 1,485 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 76,864 KB
最終ジャッジ日時 2023-09-27 22:21:57
合計ジャッジ時間 5,573 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,636 KB
testcase_01 AC 65 ms
71,264 KB
testcase_02 AC 71 ms
71,096 KB
testcase_03 AC 65 ms
71,404 KB
testcase_04 AC 66 ms
71,268 KB
testcase_05 AC 66 ms
71,472 KB
testcase_06 AC 67 ms
71,544 KB
testcase_07 AC 65 ms
71,268 KB
testcase_08 AC 89 ms
76,864 KB
testcase_09 AC 85 ms
76,572 KB
testcase_10 AC 86 ms
76,492 KB
testcase_11 AC 86 ms
76,752 KB
testcase_12 AC 94 ms
76,764 KB
testcase_13 AC 93 ms
76,732 KB
testcase_14 AC 79 ms
76,164 KB
testcase_15 AC 70 ms
75,812 KB
testcase_16 AC 77 ms
76,584 KB
testcase_17 AC 76 ms
76,140 KB
testcase_18 AC 76 ms
76,232 KB
testcase_19 AC 81 ms
76,236 KB
testcase_20 AC 81 ms
76,528 KB
testcase_21 AC 80 ms
76,168 KB
testcase_22 AC 76 ms
76,248 KB
testcase_23 AC 87 ms
76,580 KB
testcase_24 AC 87 ms
76,752 KB
testcase_25 AC 82 ms
76,716 KB
testcase_26 AC 81 ms
76,224 KB
testcase_27 AC 100 ms
76,576 KB
testcase_28 AC 75 ms
76,164 KB
testcase_29 AC 84 ms
76,700 KB
testcase_30 AC 75 ms
76,456 KB
testcase_31 AC 80 ms
76,460 KB
testcase_32 AC 87 ms
76,692 KB
testcase_33 AC 80 ms
76,548 KB
testcase_34 AC 90 ms
76,824 KB
testcase_35 AC 75 ms
76,424 KB
testcase_36 AC 82 ms
76,528 KB
testcase_37 AC 75 ms
76,512 KB
testcase_38 AC 75 ms
76,196 KB
testcase_39 AC 77 ms
76,232 KB
testcase_40 AC 75 ms
76,596 KB
testcase_41 AC 75 ms
75,952 KB
testcase_42 AC 77 ms
71,580 KB
testcase_43 AC 69 ms
75,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
C = int(input())
V = int(input())
adj_list = [[] for _ in range(N)]
S = list(map(int, input().split()))
T = list(map(int, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))

for Si, Ti, Yi, Mi in zip(S, T, Y, M):
    adj_list[Si-1].append((Ti-1, Mi, Yi))
    
dp = [[10**18 for _ in range(C+1)] for _ in range(N)]
dp[0][0] = 0

for i in range(N):
    for j in range(C+1):
        for next_node, w, m in adj_list[i]:
            if j + m <= C:
                dp[next_node][j+m] = min(dp[next_node][j+m], dp[i][j] + w)

ans = 10 ** 18

for i in range(C+1):
    ans = min(ans, dp[N-1][i])

if ans == 10 ** 18:
    print(-1)
else:
    print(ans)
0