結果

問題 No.1 道のショートカット
ユーザー roiti46roiti46
提出日時 2015-02-15 23:29:58
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 77,988 KB
実行使用メモリ 89,708 KB
最終ジャッジ日時 2023-09-22 11:57:54
合計ジャッジ時間 8,619 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
76,268 KB
testcase_01 AC 72 ms
76,088 KB
testcase_02 AC 71 ms
76,544 KB
testcase_03 AC 73 ms
76,368 KB
testcase_04 WA -
testcase_05 AC 71 ms
76,280 KB
testcase_06 AC 71 ms
76,512 KB
testcase_07 AC 72 ms
76,036 KB
testcase_08 AC 94 ms
79,552 KB
testcase_09 AC 80 ms
79,156 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 74 ms
77,268 KB
testcase_16 WA -
testcase_17 AC 72 ms
76,524 KB
testcase_18 AC 79 ms
79,104 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 73 ms
77,448 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 124 ms
80,468 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 72 ms
76,076 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 83 ms
79,184 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 69 ms
76,076 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 70 ms
76,372 KB
testcase_43 AC 72 ms
77,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

inf = 10**10
def get_paths(n,cost,time):
    if n == N-1: return time
    res = inf
    for i in xrange(n+1,N):
        if cost + G[n][i][0] > C: continue
        res = min(res,get_paths(i,cost+G[n][i][0],time+G[n][i][1]))
    return res
    
N,C,V = [int(raw_input()) for i in range(3)]
S,T,Y,M = [map(int,raw_input().split()) for i in range(4)]
G = [[[inf,inf] for i in xrange(N)] for j in xrange(N)]
for i in xrange(V): G[S[i]-1][T[i]-1] = [Y[i],M[i]]

ans = get_paths(0,0,0)
print ans if ans < inf else -1
0