結果

問題 No.1 道のショートカット
ユーザー tookunn_1213tookunn_1213
提出日時 2015-11-24 22:58:35
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 893 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 6,492 KB
実行使用メモリ 6,488 KB
最終ジャッジ日時 2023-09-22 12:31:48
合計ジャッジ時間 2,281 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,968 KB
testcase_01 AC 11 ms
6,016 KB
testcase_02 AC 10 ms
5,896 KB
testcase_03 AC 11 ms
5,952 KB
testcase_04 WA -
testcase_05 AC 10 ms
6,020 KB
testcase_06 AC 11 ms
6,036 KB
testcase_07 AC 11 ms
5,892 KB
testcase_08 AC 30 ms
6,308 KB
testcase_09 AC 15 ms
6,372 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 11 ms
6,064 KB
testcase_16 WA -
testcase_17 AC 11 ms
5,988 KB
testcase_18 AC 12 ms
6,064 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 12 ms
5,952 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 15 ms
6,232 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 11 ms
6,000 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 14 ms
6,060 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 11 ms
6,096 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 11 ms
5,964 KB
testcase_43 AC 11 ms
6,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(nowTown,money):
	if money < 0:
		return 9000000009L
	global N
	if nowTown >= N:
		return 0
	global dp
	if dp[nowTown][money] != -1:
		return dp[nowTown][money]
	global S,T,Y,M,connect,time
	ret = 9000000009L
	for i in range(nowTown + 1,N + 1):
		if connect[nowTown][i] != -1:
			ret = min(ret,dfs(i,money - connect[nowTown][i]) + time[nowTown][i])
	dp[nowTown][money] = ret
	return ret
N,C,V = int(raw_input()),int(raw_input()),int(raw_input())
S,T,Y,M = map(int,raw_input().split()),map(int,raw_input().split()),map(int,raw_input().split()),map(int,raw_input().split())
connect = [[-1 for i in range(N + 1)] for j in range(N + 1)]
time = [[-1 for i in range(N + 1)] for j in range(N + 1)]
dp = [[-1 for i in range(300 + 2)] for j in range(N + 2)]
for i in range(V):
	connect[S[i]][T[i]] = Y[i]
	time[S[i]][T[i]] = M[i]
ans = dfs(1,C)
if ans == 9000000009L:
	print -1
else:
	print ans
0