結果

問題 No.1 道のショートカット
ユーザー tookunn_1213tookunn_1213
提出日時 2016-08-23 11:30:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 105 ms / 5,000 ms
コード長 609 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 10,876 KB
実行使用メモリ 8,820 KB
最終ジャッジ日時 2023-09-27 21:59:27
合計ジャッジ時間 2,641 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,992 KB
testcase_01 AC 14 ms
7,772 KB
testcase_02 AC 15 ms
7,976 KB
testcase_03 AC 14 ms
8,056 KB
testcase_04 AC 14 ms
8,104 KB
testcase_05 AC 13 ms
7,968 KB
testcase_06 AC 13 ms
8,068 KB
testcase_07 AC 14 ms
8,124 KB
testcase_08 AC 24 ms
8,384 KB
testcase_09 AC 17 ms
7,928 KB
testcase_10 AC 22 ms
8,396 KB
testcase_11 AC 44 ms
8,020 KB
testcase_12 AC 66 ms
8,820 KB
testcase_13 AC 60 ms
8,704 KB
testcase_14 AC 15 ms
8,068 KB
testcase_15 AC 16 ms
7,964 KB
testcase_16 AC 15 ms
8,060 KB
testcase_17 AC 15 ms
8,076 KB
testcase_18 AC 16 ms
8,068 KB
testcase_19 AC 15 ms
8,104 KB
testcase_20 AC 20 ms
7,892 KB
testcase_21 AC 15 ms
8,004 KB
testcase_22 AC 15 ms
7,968 KB
testcase_23 AC 104 ms
8,064 KB
testcase_24 AC 105 ms
8,028 KB
testcase_25 AC 29 ms
8,124 KB
testcase_26 AC 21 ms
8,236 KB
testcase_27 AC 76 ms
7,980 KB
testcase_28 AC 14 ms
7,972 KB
testcase_29 AC 27 ms
8,204 KB
testcase_30 AC 16 ms
8,144 KB
testcase_31 AC 23 ms
8,116 KB
testcase_32 AC 30 ms
8,412 KB
testcase_33 AC 21 ms
8,156 KB
testcase_34 AC 75 ms
8,452 KB
testcase_35 AC 16 ms
7,984 KB
testcase_36 AC 19 ms
7,964 KB
testcase_37 AC 16 ms
7,972 KB
testcase_38 AC 14 ms
8,064 KB
testcase_39 AC 16 ms
7,924 KB
testcase_40 AC 15 ms
7,892 KB
testcase_41 AC 15 ms
8,192 KB
testcase_42 AC 13 ms
7,888 KB
testcase_43 AC 15 ms
7,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,C,V = int(input()),int(input()),int(input())
S = [int(i) - 1 for i in input().split()]
T = [int(i) - 1 for i in input().split()]
Y = [int(i) for i in input().split()]
M = [int(i) for i in input().split()]
edge = [[] for i in range(N)]
for i in range(V):
	edge[S[i]].append((T[i],Y[i],M[i]))
INF = 10 ** 9 + 7
dp = [[INF for j in range(C + 1)] for i in range(N)]
dp[0][0] = 0
for i in range(N):
	for j in range(C):
		if dp[i][j] != INF:
			for e in edge[i]:
				if j + e[1] <= C:
					dp[e[0]][j + e[1]] = min(dp[e[0]][j + e[1]],dp[i][j] + e[2])
ans = min(INF,min(dp[N - 1]))
print(-1 if ans == INF else ans)
0