結果

問題 No.1 道のショートカット
ユーザー Yuta123456Yuta123456
提出日時 2020-05-21 19:36:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 810 bytes
コンパイル時間 867 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 8,604 KB
最終ジャッジ日時 2023-09-22 13:46:43
合計ジャッジ時間 8,954 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,152 KB
testcase_01 AC 16 ms
8,168 KB
testcase_02 AC 16 ms
8,036 KB
testcase_03 AC 16 ms
8,160 KB
testcase_04 AC 16 ms
8,036 KB
testcase_05 AC 16 ms
8,112 KB
testcase_06 AC 16 ms
8,028 KB
testcase_07 AC 16 ms
8,120 KB
testcase_08 AC 19 ms
8,260 KB
testcase_09 AC 17 ms
8,328 KB
testcase_10 AC 19 ms
8,140 KB
testcase_11 AC 86 ms
8,196 KB
testcase_12 AC 29 ms
8,476 KB
testcase_13 AC 28 ms
8,604 KB
testcase_14 AC 16 ms
8,312 KB
testcase_15 AC 16 ms
8,020 KB
testcase_16 AC 16 ms
8,320 KB
testcase_17 AC 16 ms
7,992 KB
testcase_18 AC 16 ms
7,764 KB
testcase_19 AC 16 ms
8,308 KB
testcase_20 AC 17 ms
8,296 KB
testcase_21 AC 16 ms
8,280 KB
testcase_22 AC 16 ms
8,112 KB
testcase_23 TLE -
testcase_24 AC 503 ms
8,280 KB
testcase_25 AC 19 ms
8,192 KB
testcase_26 AC 18 ms
8,272 KB
testcase_27 AC 182 ms
8,164 KB
testcase_28 AC 16 ms
7,956 KB
testcase_29 AC 52 ms
8,332 KB
testcase_30 AC 20 ms
8,152 KB
testcase_31 AC 50 ms
8,392 KB
testcase_32 AC 24 ms
8,384 KB
testcase_33 AC 18 ms
8,200 KB
testcase_34 AC 123 ms
8,280 KB
testcase_35 AC 18 ms
8,192 KB
testcase_36 AC 19 ms
8,224 KB
testcase_37 AC 23 ms
8,248 KB
testcase_38 AC 16 ms
8,284 KB
testcase_39 AC 16 ms
8,280 KB
testcase_40 AC 17 ms
8,164 KB
testcase_41 AC 16 ms
7,812 KB
testcase_42 AC 16 ms
7,956 KB
testcase_43 AC 16 ms
8,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()))
adjacent_list = [[] for i in range(n+1)]
for i in range(v):
    adjacent_list[s[i]].append([t[i],y[i],m[i]])
ans = 10**9
memo = [[10**9,10**9] for i in range(n+1)]
def dfs(node,cost,time):
    if node == n:
        global ans
        ans = min(ans, time)
    if memo[node][0] < cost and memo[node][1] < time:
        return 
    if memo[node][0] > cost and memo[node][1] > time:
        memo[node] = [cost, time]
    for n_node, n_cost, n_time in adjacent_list[node]:
        if n_cost + cost <= c:
            dfs(n_node,n_cost + cost, time + n_time)
dfs(1,0,0)
if ans == 10**9:
    print(-1)
else:
    print(ans)
0