結果

問題 No.1 道のショートカット
ユーザー tnodinotnodino
提出日時 2022-01-30 14:50:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 77,200 KB
最終ジャッジ日時 2023-09-02 01:37:55
合計ジャッジ時間 6,133 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,504 KB
testcase_01 AC 67 ms
71,460 KB
testcase_02 AC 67 ms
71,576 KB
testcase_03 AC 68 ms
71,208 KB
testcase_04 AC 67 ms
71,360 KB
testcase_05 AC 71 ms
71,460 KB
testcase_06 AC 64 ms
71,696 KB
testcase_07 AC 69 ms
71,612 KB
testcase_08 AC 86 ms
76,976 KB
testcase_09 AC 86 ms
76,664 KB
testcase_10 AC 84 ms
76,808 KB
testcase_11 AC 85 ms
76,904 KB
testcase_12 AC 89 ms
76,884 KB
testcase_13 AC 90 ms
76,888 KB
testcase_14 AC 80 ms
76,204 KB
testcase_15 AC 71 ms
75,848 KB
testcase_16 AC 80 ms
76,664 KB
testcase_17 AC 76 ms
76,160 KB
testcase_18 AC 75 ms
76,112 KB
testcase_19 AC 79 ms
76,136 KB
testcase_20 AC 81 ms
76,828 KB
testcase_21 AC 76 ms
76,188 KB
testcase_22 AC 75 ms
76,208 KB
testcase_23 AC 90 ms
77,064 KB
testcase_24 AC 90 ms
77,012 KB
testcase_25 AC 81 ms
76,840 KB
testcase_26 AC 78 ms
76,104 KB
testcase_27 AC 88 ms
77,200 KB
testcase_28 AC 75 ms
76,136 KB
testcase_29 AC 81 ms
76,860 KB
testcase_30 AC 78 ms
76,708 KB
testcase_31 AC 79 ms
76,756 KB
testcase_32 AC 86 ms
76,864 KB
testcase_33 AC 87 ms
76,512 KB
testcase_34 AC 89 ms
76,916 KB
testcase_35 AC 75 ms
76,724 KB
testcase_36 AC 80 ms
76,952 KB
testcase_37 AC 79 ms
76,660 KB
testcase_38 AC 76 ms
76,176 KB
testcase_39 AC 78 ms
75,984 KB
testcase_40 AC 81 ms
76,804 KB
testcase_41 AC 78 ms
76,200 KB
testcase_42 AC 67 ms
71,284 KB
testcase_43 AC 74 ms
75,912 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 nxt,yen,minute in G[pos]:
        for i in range(C):
            if i + yen <= C:
                DP[nxt][i+yen] = min(DP[nxt][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