結果

問題 No.1 道のショートカット
ユーザー ytftytft
提出日時 2022-10-31 23:57:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 196 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 1,037 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 78,908 KB
最終ジャッジ日時 2023-09-22 20:47:52
合計ジャッジ時間 8,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,980 KB
testcase_01 AC 93 ms
71,816 KB
testcase_02 AC 93 ms
71,664 KB
testcase_03 AC 92 ms
71,536 KB
testcase_04 AC 90 ms
71,724 KB
testcase_05 AC 91 ms
71,508 KB
testcase_06 AC 93 ms
71,744 KB
testcase_07 AC 92 ms
71,976 KB
testcase_08 AC 196 ms
78,464 KB
testcase_09 AC 131 ms
78,484 KB
testcase_10 AC 133 ms
78,532 KB
testcase_11 AC 137 ms
78,788 KB
testcase_12 AC 141 ms
78,788 KB
testcase_13 AC 135 ms
78,640 KB
testcase_14 AC 111 ms
77,732 KB
testcase_15 AC 99 ms
77,196 KB
testcase_16 AC 122 ms
77,980 KB
testcase_17 AC 102 ms
77,836 KB
testcase_18 AC 116 ms
77,920 KB
testcase_19 AC 124 ms
78,564 KB
testcase_20 AC 130 ms
78,908 KB
testcase_21 AC 126 ms
78,388 KB
testcase_22 AC 117 ms
77,876 KB
testcase_23 AC 131 ms
78,556 KB
testcase_24 AC 129 ms
78,740 KB
testcase_25 AC 135 ms
78,844 KB
testcase_26 AC 128 ms
78,432 KB
testcase_27 AC 132 ms
78,768 KB
testcase_28 AC 107 ms
77,548 KB
testcase_29 AC 125 ms
78,784 KB
testcase_30 AC 116 ms
77,768 KB
testcase_31 AC 113 ms
77,936 KB
testcase_32 AC 135 ms
78,448 KB
testcase_33 AC 132 ms
78,764 KB
testcase_34 AC 130 ms
78,084 KB
testcase_35 AC 105 ms
77,908 KB
testcase_36 AC 129 ms
78,512 KB
testcase_37 AC 104 ms
77,680 KB
testcase_38 AC 108 ms
77,832 KB
testcase_39 AC 123 ms
78,264 KB
testcase_40 AC 118 ms
78,008 KB
testcase_41 AC 105 ms
77,456 KB
testcase_42 AC 92 ms
71,612 KB
testcase_43 AC 98 ms
77,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,datetime
input=lambda:sys.stdin.readline().rstrip()
N,C,V=[int(input()) for i in range(3)]
S,T,Y,M=[list(map(int,input().split())) for i in range(4)]
con=[[] for i in range(N)]
for i in range(V):
	con[S[i]-1].append(i)
dp=[[float('inf') for i in range(C+1)] for j in range(N)]
dp[0][C]=0
for i in range(N):
	for j in range(C,-1,-1):
		for k in con[i]:
			if j-Y[k]>=0:
				dp[T[k]-1][j-Y[k]]=min(dp[T[k]-1][j-Y[k]],dp[i][j]+M[k])
ans=min(dp[N-1])
print(-1 if ans==float('inf') else ans)
0