結果

問題 No.1 道のショートカット
ユーザー gahougahou
提出日時 2016-11-10 18:04:07
言語 Python2
(2.7.18)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 545 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 6,648 KB
実行使用メモリ 6,372 KB
最終ジャッジ日時 2023-09-27 22:01:37
合計ジャッジ時間 3,266 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,924 KB
testcase_01 AC 9 ms
5,860 KB
testcase_02 AC 10 ms
5,864 KB
testcase_03 AC 10 ms
5,964 KB
testcase_04 AC 9 ms
5,940 KB
testcase_05 AC 9 ms
6,128 KB
testcase_06 AC 9 ms
5,940 KB
testcase_07 AC 9 ms
5,940 KB
testcase_08 AC 124 ms
6,116 KB
testcase_09 AC 69 ms
6,284 KB
testcase_10 AC 41 ms
6,240 KB
testcase_11 AC 67 ms
6,052 KB
testcase_12 AC 166 ms
6,372 KB
testcase_13 AC 161 ms
6,324 KB
testcase_14 AC 18 ms
5,908 KB
testcase_15 AC 10 ms
5,892 KB
testcase_16 AC 31 ms
6,136 KB
testcase_17 AC 10 ms
5,940 KB
testcase_18 AC 17 ms
5,896 KB
testcase_19 AC 25 ms
5,952 KB
testcase_20 AC 27 ms
6,148 KB
testcase_21 AC 33 ms
5,948 KB
testcase_22 AC 21 ms
5,992 KB
testcase_23 AC 119 ms
6,048 KB
testcase_24 AC 145 ms
6,060 KB
testcase_25 AC 50 ms
5,972 KB
testcase_26 AC 38 ms
6,180 KB
testcase_27 AC 102 ms
6,060 KB
testcase_28 AC 10 ms
5,996 KB
testcase_29 AC 29 ms
6,040 KB
testcase_30 AC 13 ms
5,916 KB
testcase_31 AC 24 ms
5,964 KB
testcase_32 AC 87 ms
6,288 KB
testcase_33 AC 61 ms
6,176 KB
testcase_34 AC 105 ms
6,212 KB
testcase_35 AC 13 ms
6,096 KB
testcase_36 AC 26 ms
6,100 KB
testcase_37 AC 13 ms
6,148 KB
testcase_38 AC 12 ms
6,116 KB
testcase_39 AC 25 ms
6,204 KB
testcase_40 AC 14 ms
6,008 KB
testcase_41 AC 11 ms
5,968 KB
testcase_42 AC 9 ms
5,940 KB
testcase_43 AC 9 ms
6,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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())
edge=[]
for i in xrange(V):
  edge.append((S[i]-1,T[i]-1,Y[i], M[i]))
edge=sorted(edge)
dp=[[10**9]*(C+1) for _ in xrange(N)]
dp[0][C]=0

for e in edge:
  for j in xrange(C+1):
    if j+e[2]>C: continue
    dp[e[1]][j] = min(dp[e[1]][j], dp[e[0]][j+e[2]]+e[3])

ans = 10**9
for i in xrange(C+1):
  ans = min(ans, dp[N-1][i])
if ans==10**9: print -1
else: print ans
0