結果

問題 No.1 道のショートカット
ユーザー AEnAEn
提出日時 2022-12-10 16:51:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 324 ms / 5,000 ms
コード長 514 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 83,884 KB
最終ジャッジ日時 2024-04-23 00:35:15
合計ジャッジ時間 7,324 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
52,584 KB
testcase_01 AC 34 ms
54,044 KB
testcase_02 AC 34 ms
52,468 KB
testcase_03 AC 34 ms
52,892 KB
testcase_04 AC 34 ms
53,204 KB
testcase_05 AC 35 ms
52,884 KB
testcase_06 AC 34 ms
53,892 KB
testcase_07 AC 38 ms
60,468 KB
testcase_08 AC 300 ms
82,964 KB
testcase_09 AC 161 ms
81,492 KB
testcase_10 AC 122 ms
79,072 KB
testcase_11 AC 160 ms
78,576 KB
testcase_12 AC 324 ms
83,884 KB
testcase_13 AC 311 ms
83,740 KB
testcase_14 AC 78 ms
77,532 KB
testcase_15 AC 42 ms
64,708 KB
testcase_16 AC 105 ms
80,588 KB
testcase_17 AC 39 ms
60,804 KB
testcase_18 AC 85 ms
79,140 KB
testcase_19 AC 90 ms
79,836 KB
testcase_20 AC 115 ms
79,176 KB
testcase_21 AC 121 ms
79,636 KB
testcase_22 AC 82 ms
78,340 KB
testcase_23 AC 188 ms
77,428 KB
testcase_24 AC 213 ms
77,672 KB
testcase_25 AC 124 ms
78,304 KB
testcase_26 AC 107 ms
77,420 KB
testcase_27 AC 310 ms
80,464 KB
testcase_28 AC 47 ms
66,524 KB
testcase_29 AC 136 ms
78,076 KB
testcase_30 AC 75 ms
75,496 KB
testcase_31 AC 74 ms
75,576 KB
testcase_32 AC 201 ms
81,852 KB
testcase_33 AC 145 ms
80,576 KB
testcase_34 AC 164 ms
77,612 KB
testcase_35 AC 46 ms
66,428 KB
testcase_36 AC 120 ms
78,412 KB
testcase_37 AC 90 ms
76,888 KB
testcase_38 AC 53 ms
66,720 KB
testcase_39 AC 101 ms
80,448 KB
testcase_40 AC 88 ms
77,420 KB
testcase_41 AC 59 ms
68,344 KB
testcase_42 AC 37 ms
59,468 KB
testcase_43 AC 41 ms
65,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = int(input())
V = int(input())
edge = [list(map(int, input().split())) for _ in range(4)]

dp = [[[float('inf')]*(C+1) for _ in range(N)] for _ in range(N+1)]
dp[0][0][C] = 0
res = float('inf')
for i in range(1,N+1):
    for j in range(V):
        s,t,y,m = edge[0][j],edge[1][j],edge[2][j],edge[3][j]
        s-=1;t-=1
        for k in range(y,C+1):
            dp[i][t][k-y] = min(dp[i][t][k-y],dp[i-1][s][k]+m)
    res = min(res,min(dp[i][N-1]))
print(-1 if res==float('inf') else res)
    
0