結果

問題 No.1 道のショートカット
ユーザー syunsukesyunsuke
提出日時 2019-10-29 22:39:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 266 ms / 5,000 ms
コード長 617 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 11,064 KB
実行使用メモリ 8,920 KB
最終ジャッジ日時 2023-09-27 22:23:59
合計ジャッジ時間 4,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,856 KB
testcase_01 AC 14 ms
7,856 KB
testcase_02 AC 15 ms
7,840 KB
testcase_03 AC 15 ms
7,908 KB
testcase_04 AC 14 ms
7,856 KB
testcase_05 AC 15 ms
7,780 KB
testcase_06 AC 13 ms
7,904 KB
testcase_07 AC 14 ms
7,908 KB
testcase_08 AC 218 ms
8,512 KB
testcase_09 AC 114 ms
8,284 KB
testcase_10 AC 66 ms
8,236 KB
testcase_11 AC 96 ms
8,284 KB
testcase_12 AC 264 ms
8,920 KB
testcase_13 AC 266 ms
8,816 KB
testcase_14 AC 29 ms
8,332 KB
testcase_15 AC 15 ms
8,288 KB
testcase_16 AC 49 ms
8,332 KB
testcase_17 AC 16 ms
7,908 KB
testcase_18 AC 26 ms
8,236 KB
testcase_19 AC 39 ms
8,252 KB
testcase_20 AC 44 ms
8,380 KB
testcase_21 AC 57 ms
8,400 KB
testcase_22 AC 36 ms
8,332 KB
testcase_23 AC 185 ms
8,288 KB
testcase_24 AC 226 ms
8,300 KB
testcase_25 AC 80 ms
8,280 KB
testcase_26 AC 61 ms
8,392 KB
testcase_27 AC 168 ms
8,288 KB
testcase_28 AC 18 ms
7,776 KB
testcase_29 AC 43 ms
8,372 KB
testcase_30 AC 19 ms
8,408 KB
testcase_31 AC 37 ms
8,300 KB
testcase_32 AC 146 ms
8,544 KB
testcase_33 AC 101 ms
8,284 KB
testcase_34 AC 169 ms
8,544 KB
testcase_35 AC 17 ms
8,244 KB
testcase_36 AC 40 ms
8,272 KB
testcase_37 AC 18 ms
8,380 KB
testcase_38 AC 19 ms
7,848 KB
testcase_39 AC 44 ms
8,328 KB
testcase_40 AC 19 ms
8,396 KB
testcase_41 AC 15 ms
7,988 KB
testcase_42 AC 14 ms
7,824 KB
testcase_43 AC 16 ms
8,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
C=int(input())
V=int(input())
L=[[]for i in range(N+1)]
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 i in range(V):
    L[S[i]].append([T[i],Y[i],M[i]])
    
dp=[[10**4 for i in range(C+1)]for j in range(N+1)]
dp[1][0]=0

for i in range(1,N+1):
    for j in range(C+1):
        for k in range(len(L[i])):
            if j+L[i][k][1]<=C:
                dp[L[i][k][0]][j+L[i][k][1]]=min(dp[L[i][k][0]][j+L[i][k][1]],dp[i][j]+L[i][k][2])
if min(dp[-1])>=10**4:
    print(-1)
else:
    print(min(dp[-1]))
        
0