結果

問題 No.1 道のショートカット
ユーザー tnodinotnodino
提出日時 2022-01-30 13:28:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 77,040 KB
最終ジャッジ日時 2023-09-02 01:32:52
合計ジャッジ時間 6,884 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,648 KB
testcase_01 AC 70 ms
71,400 KB
testcase_02 AC 72 ms
71,480 KB
testcase_03 AC 73 ms
71,400 KB
testcase_04 AC 73 ms
71,452 KB
testcase_05 AC 73 ms
71,700 KB
testcase_06 AC 72 ms
71,460 KB
testcase_07 AC 73 ms
71,192 KB
testcase_08 AC 93 ms
77,040 KB
testcase_09 AC 88 ms
76,840 KB
testcase_10 AC 89 ms
76,852 KB
testcase_11 AC 91 ms
76,700 KB
testcase_12 AC 95 ms
76,688 KB
testcase_13 AC 94 ms
76,844 KB
testcase_14 AC 82 ms
76,024 KB
testcase_15 AC 77 ms
75,744 KB
testcase_16 AC 82 ms
76,644 KB
testcase_17 AC 80 ms
76,144 KB
testcase_18 AC 81 ms
76,056 KB
testcase_19 AC 81 ms
76,336 KB
testcase_20 AC 86 ms
76,660 KB
testcase_21 AC 79 ms
76,136 KB
testcase_22 AC 80 ms
76,156 KB
testcase_23 AC 93 ms
76,724 KB
testcase_24 AC 91 ms
76,976 KB
testcase_25 AC 86 ms
76,728 KB
testcase_26 AC 85 ms
76,248 KB
testcase_27 AC 94 ms
77,028 KB
testcase_28 AC 78 ms
76,096 KB
testcase_29 AC 89 ms
76,704 KB
testcase_30 AC 81 ms
76,556 KB
testcase_31 AC 88 ms
76,552 KB
testcase_32 AC 89 ms
76,584 KB
testcase_33 AC 88 ms
76,636 KB
testcase_34 AC 93 ms
76,720 KB
testcase_35 AC 78 ms
76,720 KB
testcase_36 AC 85 ms
76,792 KB
testcase_37 AC 81 ms
76,736 KB
testcase_38 AC 79 ms
76,088 KB
testcase_39 AC 82 ms
76,236 KB
testcase_40 AC 83 ms
76,684 KB
testcase_41 AC 81 ms
76,096 KB
testcase_42 AC 72 ms
71,348 KB
testcase_43 AC 76 ms
75,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1<<32
N = int(input())
C = int(input())
V = int(input())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
Y = list(map(int,input().split()))
M = list(map(int,input().split()))
G = [[] for _ in range(N)]
for i in range(V):
    G[S[i]-1].append((T[i]-1, Y[i], M[i]))
DP = [[INF] * (C+1) for _ in range(N)]
DP[0][0] = 0
for pos in range(N):
    for pre,yen,minute in G[pos]:
        for i in range(C):
            if i + yen <= C:
                DP[pre][i+yen] = min(DP[pre][i+yen], DP[pos][i] + minute)
    for i in range(C):
        DP[pos][i+1] = min(DP[pos][i], DP[pos][i+1])
if DP[-1][-1] == INF:
    print(-1)
else:
    print(DP[-1][-1])
0