結果

問題 No.1 道のショートカット
ユーザー otsunekootsuneko
提出日時 2021-04-24 09:31:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 814 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 740,908 KB
最終ジャッジ日時 2023-09-17 13:30:54
合計ジャッジ時間 7,507 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,292 KB
testcase_01 AC 16 ms
7,820 KB
testcase_02 AC 16 ms
7,828 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 16 ms
7,912 KB
testcase_05 AC 16 ms
7,844 KB
testcase_06 AC 16 ms
7,880 KB
testcase_07 AC 16 ms
7,812 KB
testcase_08 AC 23 ms
8,232 KB
testcase_09 AC 18 ms
8,220 KB
testcase_10 AC 29 ms
8,548 KB
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)

def dfs(s,y,m):
    global cost_time
    if s == N-1:
        cost_time.append((y,m))
    for to, cost, time in adj[s]:
        if y + cost <= C:
            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]))

del S
del T
del Y
del M

cost_time = []
dfs(0,0,0)

ans = float("INF")
for cost,time in cost_time:
    if cost <= C:
        ans = min(ans,time)
ans = -1 if ans == float("INF") else ans
print(ans)
0