結果

問題 No.1 道のショートカット
ユーザー tookunn_1213tookunn_1213
提出日時 2015-11-24 21:31:19
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 847 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 6,724 KB
実行使用メモリ 10,484 KB
最終ジャッジ日時 2023-09-22 12:32:17
合計ジャッジ時間 9,696 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,964 KB
testcase_01 AC 11 ms
5,928 KB
testcase_02 AC 11 ms
6,140 KB
testcase_03 AC 11 ms
6,024 KB
testcase_04 WA -
testcase_05 AC 11 ms
5,892 KB
testcase_06 AC 11 ms
6,140 KB
testcase_07 AC 11 ms
6,084 KB
testcase_08 AC 42 ms
6,044 KB
testcase_09 AC 14 ms
5,992 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 11 ms
6,096 KB
testcase_16 WA -
testcase_17 AC 11 ms
5,952 KB
testcase_18 AC 11 ms
5,876 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 11 ms
5,952 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 28 ms
6,112 KB
testcase_26 WA -
testcase_27 TLE -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def dfs(nowTown,money,cost):
	if money < 0:
		return 1000000009
	if nowTown == len(cost) - 1:
		return 0
	global S,T,Y,M,connect,time
	ret = 1000000009
	for i in range(nowTown + 1,len(cost)):
		if connect[nowTown][i] != -1:
			ret = min(ret,dfs(i,money - connect[nowTown][i],cost) + time[nowTown][i])
	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)]
for i in range(V):
	connect[S[i]][T[i]] = Y[i]
	connect[T[i]][S[i]] = Y[i]
	time[S[i]][T[i]] = time[T[i]][S[i]] = M[i]
cost = [1000000009 for i in range(N + 1)]
ans = dfs(1,C,cost)
if ans == 1000000009:
	print -1
else:
	print ans
0