結果

問題 No.1 道のショートカット
ユーザー ayame_pyayame_py
提出日時 2015-10-07 23:00:27
言語 Python2
(2.7.18)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 730 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 6,756 KB
実行使用メモリ 6,468 KB
最終ジャッジ日時 2023-09-27 21:48:08
合計ジャッジ時間 3,377 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
5,868 KB
testcase_01 AC 12 ms
5,892 KB
testcase_02 AC 11 ms
6,112 KB
testcase_03 AC 11 ms
5,940 KB
testcase_04 AC 11 ms
5,960 KB
testcase_05 AC 11 ms
6,052 KB
testcase_06 AC 11 ms
6,052 KB
testcase_07 AC 11 ms
5,864 KB
testcase_08 AC 25 ms
6,220 KB
testcase_09 AC 16 ms
6,264 KB
testcase_10 AC 21 ms
6,116 KB
testcase_11 AC 42 ms
6,168 KB
testcase_12 AC 66 ms
6,468 KB
testcase_13 AC 61 ms
6,324 KB
testcase_14 AC 13 ms
6,092 KB
testcase_15 AC 13 ms
5,928 KB
testcase_16 AC 14 ms
6,232 KB
testcase_17 AC 12 ms
5,908 KB
testcase_18 AC 12 ms
5,924 KB
testcase_19 AC 14 ms
6,228 KB
testcase_20 AC 18 ms
6,032 KB
testcase_21 AC 14 ms
6,132 KB
testcase_22 AC 12 ms
6,100 KB
testcase_23 AC 101 ms
6,052 KB
testcase_24 AC 96 ms
6,060 KB
testcase_25 AC 26 ms
6,244 KB
testcase_26 AC 18 ms
5,936 KB
testcase_27 AC 76 ms
6,164 KB
testcase_28 AC 12 ms
5,888 KB
testcase_29 AC 26 ms
6,044 KB
testcase_30 AC 14 ms
5,916 KB
testcase_31 AC 23 ms
6,192 KB
testcase_32 AC 30 ms
6,216 KB
testcase_33 AC 21 ms
6,096 KB
testcase_34 AC 76 ms
6,152 KB
testcase_35 AC 14 ms
6,040 KB
testcase_36 AC 17 ms
6,020 KB
testcase_37 AC 15 ms
6,280 KB
testcase_38 AC 12 ms
6,136 KB
testcase_39 AC 14 ms
5,992 KB
testcase_40 AC 13 ms
6,012 KB
testcase_41 AC 12 ms
6,012 KB
testcase_42 AC 11 ms
5,984 KB
testcase_43 AC 13 ms
6,196 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 = int(1e9+7)

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

toList = [[] for _ in xrange(N)]

for i in xrange(V):
	toList[S[i]-1].append((T[i]-1, Y[i], M[i]))

for i in xrange(N):
	for k in xrange(C+1):
		if dp[i][k]!=INF:
			for t, y, m in toList[i]:
				if k + y <= C:
					dp[t][k+y]=min(dp[t][k+y], dp[i][k]+m)

res = min(dp[N-1])
if res==INF: print -1
else: print res
0