結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,912 KB
testcase_01 AC 11 ms
5,932 KB
testcase_02 AC 11 ms
5,960 KB
testcase_03 AC 11 ms
5,976 KB
testcase_04 WA -
testcase_05 AC 12 ms
5,928 KB
testcase_06 AC 11 ms
5,972 KB
testcase_07 AC 11 ms
5,952 KB
testcase_08 AC 27 ms
6,164 KB
testcase_09 AC 14 ms
6,196 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 11 ms
6,204 KB
testcase_16 WA -
testcase_17 AC 11 ms
5,968 KB
testcase_18 AC 12 ms
6,180 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 13 ms
6,012 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 15 ms
5,948 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 12 ms
5,936 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 14 ms
6,116 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 12 ms
5,960 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 11 ms
5,920 KB
testcase_43 AC 12 ms
6,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(nowTown,money):
	if money < 0:
		return 9000000009
	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 = 9000000009
	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 == 9000000009:
	print -1
else:
	print ans
0