結果

問題 No.2387 Yokan Factory
ユーザー えなじ~🔋▶️えなじ~🔋▶️
提出日時 2023-07-21 21:52:51
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,228 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,660 KB
実行使用メモリ 286,552 KB
最終ジャッジ日時 2023-10-21 21:54:26
合計ジャッジ時間 32,059 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,476 KB
testcase_01 AC 43 ms
53,456 KB
testcase_02 AC 41 ms
53,456 KB
testcase_03 AC 40 ms
53,456 KB
testcase_04 AC 40 ms
53,456 KB
testcase_05 AC 40 ms
53,456 KB
testcase_06 AC 40 ms
53,456 KB
testcase_07 AC 40 ms
53,456 KB
testcase_08 AC 40 ms
53,456 KB
testcase_09 AC 40 ms
53,456 KB
testcase_10 AC 40 ms
53,456 KB
testcase_11 AC 40 ms
53,456 KB
testcase_12 AC 40 ms
53,456 KB
testcase_13 AC 40 ms
53,456 KB
testcase_14 AC 40 ms
53,456 KB
testcase_15 AC 3,084 ms
272,068 KB
testcase_16 AC 2,588 ms
274,968 KB
testcase_17 TLE -
testcase_18 AC 4,815 ms
272,360 KB
testcase_19 AC 4,264 ms
270,504 KB
testcase_20 AC 3,304 ms
263,840 KB
testcase_21 TLE -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq

N, M, X = map(int, input().split())
adj_list = []
for _ in range(M):
    u,v,a,b = map(int, input().split())
    adj_list.append([u,v,a,b])

small = -1
large = 10**9 + 1
while(large-small>1):
    middle = (large + small)//2
    #print(large, middle, small)
    # 大きさmiddleのようかんをX分以内に輸送できるか?
    adj = [[] for _ in range(N)]
    for u,v,a,b in adj_list:
        if middle <= b:
            adj[u-1].append((v-1, a))
            adj[v-1].append((u-1, a))
    new_adj = []
    for l in adj:
        p = {}
        for v,a in l:
            if v in p.keys():
                p[v] = min(p[v], a)
            else:
                p[v] = a
        new_adj.append([(v,p[v]) for v in p.keys()])
    adj = new_adj


    times = [-1 for _ in range(N)]
    q = [(0, 0)]
    heapq.heapify(q)

    #print(adj)

    while(len(q)>0):
        time, node = heapq.heappop(q)
        if times[node]==-1:
            times[node] = time
            for v, d in adj[node]:
                heapq.heappush(q, (time+d, v))
    #print(times)
    if times[N-1]==-1 or times[N-1]>X:
        #運べなかった
        large = middle
    else:
        #運べた
        small = middle

print(small)


0