結果

問題 No.1 道のショートカット
ユーザー ayame_pyayame_py
提出日時 2015-10-07 15:30:09
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 973 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 6,508 KB
実行使用メモリ 6,688 KB
最終ジャッジ日時 2023-09-22 12:31:07
合計ジャッジ時間 3,828 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,848 KB
testcase_01 AC 12 ms
5,940 KB
testcase_02 AC 11 ms
5,960 KB
testcase_03 AC 11 ms
5,868 KB
testcase_04 WA -
testcase_05 AC 11 ms
6,024 KB
testcase_06 AC 11 ms
6,028 KB
testcase_07 AC 11 ms
5,956 KB
testcase_08 AC 86 ms
6,268 KB
testcase_09 AC 31 ms
6,372 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 13 ms
6,016 KB
testcase_16 WA -
testcase_17 AC 12 ms
6,004 KB
testcase_18 AC 16 ms
6,032 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 27 ms
6,052 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 51 ms
6,008 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 12 ms
5,956 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 34 ms
6,212 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 12 ms
5,884 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 11 ms
6,032 KB
testcase_43 AC 13 ms
6,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
N = int(raw_input())
C = int(raw_input())
V = int(raw_input())
S = map(int, raw_input().split())
T = map(int, raw_input().split())
Y = map(int, raw_input().split())
M = map(int, raw_input().split())

INF = 1e9+7

# dpテーブル
# dp[i][k]=i番目の街で、所持金kの時の最短経路
# 辿りつけない時はINF
dp = [[INF for _ in range(C+1)] for _ in range(N)]
for i in range(C+1):
	dp[0][i]=0

next_town = [[] for _ in range(N)]
cost = [[INF for _ in range(N)] for _ in range(N)]
time = [[INF for _ in range(N)] for _ in range(N)]

for i in range(V):
	next_town[S[i]-1].append(T[i]-1)
	cost[S[i]-1][T[i]-1] = Y[i]
	time[S[i]-1][T[i]-1] = M[i]

for i in range(N):
	for k in range(C+1):
		if dp[i][k]!=INF:
			for j in next_town[i]:
				if k + cost[i][j] <= C:
					dp[j][k+cost[i][j]]=min(dp[j][k+cost[i][j]],dp[i][k]+time[i][j])

res = INF
for i in range(C+1):
	res = min(res, dp[N-1][i])

if dp[N-1][C] == INF: print -1
else: print dp[N-1][C]
0