結果

問題 No.1 道のショートカット
ユーザー akasia_midoriakasia_midori
提出日時 2022-05-03 10:53:40
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 989 bytes
コンパイル時間 2,464 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 78,876 KB
最終ジャッジ日時 2023-09-15 08:50:45
合計ジャッジ時間 7,864 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
70,976 KB
testcase_01 AC 76 ms
71,216 KB
testcase_02 AC 76 ms
71,032 KB
testcase_03 AC 76 ms
71,244 KB
testcase_04 AC 76 ms
70,996 KB
testcase_05 AC 76 ms
70,988 KB
testcase_06 AC 76 ms
70,912 KB
testcase_07 AC 75 ms
71,132 KB
testcase_08 AC 96 ms
76,588 KB
testcase_09 AC 83 ms
75,500 KB
testcase_10 AC 83 ms
75,460 KB
testcase_11 AC 93 ms
76,428 KB
testcase_12 AC 94 ms
76,608 KB
testcase_13 AC 94 ms
76,684 KB
testcase_14 AC 75 ms
70,984 KB
testcase_15 RE -
testcase_16 AC 82 ms
75,500 KB
testcase_17 RE -
testcase_18 AC 76 ms
71,188 KB
testcase_19 AC 77 ms
71,204 KB
testcase_20 AC 80 ms
75,636 KB
testcase_21 AC 77 ms
71,184 KB
testcase_22 AC 78 ms
71,240 KB
testcase_23 AC 113 ms
78,248 KB
testcase_24 AC 97 ms
76,624 KB
testcase_25 AC 81 ms
75,588 KB
testcase_26 AC 77 ms
71,256 KB
testcase_27 AC 96 ms
76,428 KB
testcase_28 AC 77 ms
71,304 KB
testcase_29 AC 98 ms
76,616 KB
testcase_30 AC 83 ms
75,552 KB
testcase_31 AC 87 ms
75,372 KB
testcase_32 AC 85 ms
75,448 KB
testcase_33 AC 82 ms
75,536 KB
testcase_34 AC 95 ms
76,724 KB
testcase_35 AC 87 ms
75,948 KB
testcase_36 AC 85 ms
75,380 KB
testcase_37 AC 85 ms
75,752 KB
testcase_38 AC 78 ms
71,240 KB
testcase_39 AC 78 ms
71,248 KB
testcase_40 AC 81 ms
75,440 KB
testcase_41 AC 77 ms
71,256 KB
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import heapq

input_count = 0
N = int(input())
C = int(input())
V = int(input())

S = many_int()
T = many_int()
Y = many_int()
M = many_int()

G = {i:[] for i in range(V)}
temp_G = {i:set([]) for i in range(V)}

for i in range(V):
    temp_G[S[i]-1].add(f"{T[i]-1}_{M[i]}_{Y[i]}")
    
for k, v in temp_G.items():
    
    for vv in v:
        t,m,y = vv.split("_")
        G[k].append((int(t), int(m), int(y)))

G

q = [[0,0,0]]

mins = 10**10
while q:
    all_minute, all_cost, now_node = heapq.heappop(q)
    if now_node == (N-1):
        mins = min(mins, all_minute)
        break
        continue
    
    for next_node, next_minute, next_cost in G[now_node]:
        if (all_cost + next_cost) > C:
            continue
        else:
            heapq.heappush(q, (all_minute+next_minute, all_cost+next_cost, next_node))
            

if mins == 10**10:
    print(-1)
else:
    print(mins)
0