結果

問題 No.1 道のショートカット
ユーザー otsunekootsuneko
提出日時 2021-04-24 10:59:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 5,000 ms
コード長 741 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 76,700 KB
最終ジャッジ日時 2023-09-17 13:33:33
合計ジャッジ時間 5,348 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,460 KB
testcase_01 AC 73 ms
71,432 KB
testcase_02 AC 73 ms
71,556 KB
testcase_03 AC 74 ms
71,368 KB
testcase_04 AC 74 ms
71,348 KB
testcase_05 AC 73 ms
71,308 KB
testcase_06 AC 73 ms
71,564 KB
testcase_07 AC 73 ms
71,472 KB
testcase_08 AC 85 ms
76,584 KB
testcase_09 AC 78 ms
76,064 KB
testcase_10 AC 85 ms
76,368 KB
testcase_11 AC 80 ms
76,372 KB
testcase_12 AC 87 ms
76,576 KB
testcase_13 AC 82 ms
76,688 KB
testcase_14 AC 73 ms
71,312 KB
testcase_15 AC 74 ms
71,340 KB
testcase_16 AC 75 ms
75,848 KB
testcase_17 AC 70 ms
71,220 KB
testcase_18 AC 72 ms
71,432 KB
testcase_19 AC 72 ms
71,192 KB
testcase_20 AC 75 ms
75,620 KB
testcase_21 AC 71 ms
71,456 KB
testcase_22 AC 73 ms
71,532 KB
testcase_23 AC 87 ms
76,580 KB
testcase_24 AC 84 ms
76,556 KB
testcase_25 AC 75 ms
75,748 KB
testcase_26 AC 81 ms
75,972 KB
testcase_27 AC 88 ms
76,700 KB
testcase_28 AC 71 ms
71,340 KB
testcase_29 AC 88 ms
76,560 KB
testcase_30 AC 81 ms
76,148 KB
testcase_31 AC 85 ms
76,336 KB
testcase_32 AC 83 ms
76,396 KB
testcase_33 AC 80 ms
76,272 KB
testcase_34 AC 89 ms
76,580 KB
testcase_35 AC 78 ms
75,724 KB
testcase_36 AC 81 ms
76,144 KB
testcase_37 AC 84 ms
76,456 KB
testcase_38 AC 75 ms
71,340 KB
testcase_39 AC 74 ms
71,292 KB
testcase_40 AC 77 ms
75,952 KB
testcase_41 AC 74 ms
71,456 KB
testcase_42 AC 74 ms
71,432 KB
testcase_43 AC 74 ms
71,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)

def dfs(s,y,m):
    global ans
    global cost_time

    if s == N-1 and y <= C:
        ans = min(ans,m)
    for to, cost, time in adj[s]:
        if y + cost <= C and m < ans:
            dfs(to,y+cost,m+time)
                
# 入力の受け取り・隣接リストadjの構築:
N = int(input())
C = int(input())
V = int(input())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
Y = list(map(int,input().split()))
M = list(map(int,input().split()))

adj = [[] for _ in range(N)]
for i in range(V):
    adj[S[i]-1].append((T[i]-1, Y[i], M[i]))

ans = float("INF")
cost_time = []
dfs(0,0,0)

ans = -1 if ans == float("INF") else ans
print(ans)
0