結果

問題 No.1 道のショートカット
ユーザー HydruHydru
提出日時 2023-01-15 10:48:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 77,980 KB
最終ジャッジ日時 2023-08-27 18:35:07
合計ジャッジ時間 7,125 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,008 KB
testcase_01 AC 72 ms
71,296 KB
testcase_02 AC 71 ms
71,120 KB
testcase_03 AC 71 ms
70,876 KB
testcase_04 AC 70 ms
71,312 KB
testcase_05 AC 70 ms
70,936 KB
testcase_06 AC 71 ms
70,860 KB
testcase_07 AC 75 ms
70,960 KB
testcase_08 AC 98 ms
76,744 KB
testcase_09 AC 92 ms
76,852 KB
testcase_10 AC 97 ms
76,848 KB
testcase_11 AC 106 ms
77,840 KB
testcase_12 AC 108 ms
77,980 KB
testcase_13 AC 102 ms
77,412 KB
testcase_14 AC 83 ms
76,336 KB
testcase_15 AC 72 ms
71,004 KB
testcase_16 AC 89 ms
76,492 KB
testcase_17 AC 72 ms
70,932 KB
testcase_18 AC 87 ms
76,344 KB
testcase_19 AC 84 ms
76,328 KB
testcase_20 AC 93 ms
76,768 KB
testcase_21 AC 93 ms
76,520 KB
testcase_22 AC 86 ms
76,092 KB
testcase_23 AC 103 ms
77,576 KB
testcase_24 AC 99 ms
76,824 KB
testcase_25 AC 92 ms
76,564 KB
testcase_26 AC 93 ms
76,544 KB
testcase_27 AC 99 ms
77,224 KB
testcase_28 AC 78 ms
75,920 KB
testcase_29 AC 96 ms
76,756 KB
testcase_30 AC 84 ms
76,380 KB
testcase_31 AC 86 ms
76,816 KB
testcase_32 AC 95 ms
76,776 KB
testcase_33 AC 95 ms
76,780 KB
testcase_34 AC 94 ms
76,720 KB
testcase_35 AC 80 ms
76,696 KB
testcase_36 AC 96 ms
77,020 KB
testcase_37 AC 81 ms
76,692 KB
testcase_38 AC 80 ms
76,156 KB
testcase_39 AC 85 ms
76,032 KB
testcase_40 AC 87 ms
76,328 KB
testcase_41 AC 77 ms
76,296 KB
testcase_42 AC 72 ms
71,104 KB
testcase_43 AC 70 ms
71,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
C=int(input())
V=int(input())

S=list(map(lambda x:int(x)-1,input().split()))
T=list(map(lambda x:int(x)-1,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]].append((T[i],Y[i],M[i]))

inf=float("inf")

DP=[[inf]*(C+1) for _ in range(N)]

DP[0][0]=0
for i in range(N-1):
    for u,m,t in G[i]:
        for j in range(C+1):
            if j+m>C:
                break
            DP[u][j+m]=min(DP[u][j+m],DP[i][j]+t)

ans=min(DP[N-1])

if ans==inf:
    print(-1)
else:
    print(ans)
0