結果

問題 No.1607 Kth Maximum Card
ユーザー rlangevinrlangevin
提出日時 2023-10-04 08:58:27
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,017 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 87,068 KB
実行使用メモリ 351,300 KB
最終ジャッジ日時 2023-10-04 08:59:02
合計ジャッジ時間 9,621 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,540 KB
testcase_01 AC 90 ms
71,812 KB
testcase_02 AC 90 ms
71,676 KB
testcase_03 AC 94 ms
71,588 KB
testcase_04 AC 93 ms
71,856 KB
testcase_05 AC 91 ms
71,804 KB
testcase_06 AC 92 ms
71,584 KB
testcase_07 AC 118 ms
71,536 KB
testcase_08 TLE -
testcase_09 AC 335 ms
119,044 KB
testcase_10 AC 486 ms
137,476 KB
testcase_11 AC 164 ms
91,724 KB
testcase_12 AC 337 ms
120,860 KB
testcase_13 AC 357 ms
106,988 KB
testcase_14 AC 412 ms
129,240 KB
testcase_15 AC 2,251 ms
294,460 KB
testcase_16 AC 143 ms
84,708 KB
testcase_17 AC 171 ms
84,512 KB
testcase_18 AC 1,386 ms
292,832 KB
testcase_19 AC 763 ms
196,260 KB
testcase_20 AC 1,261 ms
289,516 KB
testcase_21 AC 1,360 ms
296,340 KB
testcase_22 AC 3,079 ms
351,300 KB
testcase_23 AC 3,079 ms
350,840 KB
testcase_24 AC 1,006 ms
237,008 KB
testcase_25 AC 499 ms
142,540 KB
testcase_26 AC 697 ms
161,276 KB
testcase_27 AC 1,128 ms
243,844 KB
testcase_28 AC 853 ms
190,512 KB
testcase_29 AC 302 ms
109,312 KB
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
Edge = []
for i in range(M):
    u, v, c = map(int, input().split())
    u, v = u - 1, v - 1
    Edge.append((u, v, c))

from collections import *
def check(m):
    G = [[] for i in range(N)]
    for u, v, c in Edge:
        if c > m:
            G[u].append((v, 1))
            G[v].append((u, 1))
        else:
            G[u].append((v, 0))
            G[v].append((u, 0))

    Q = deque()
    inf = 10 ** 18
    dist = [inf] * N
    dist[0] = 0
    Q.append(0)
    while Q:
        u = Q.popleft()
        for v, c in G[u]:
            if dist[v] <= dist[u] + c:
                continue
            dist[v] = dist[u] + c
            if c == 0:
                Q.appendleft(v)
            else:
                Q.append(v)

    return dist[-1] < K


if check(0):
    print(0)
    exit()

yes = 2 * 10 ** 5 + 5
no = 0
while yes - no != 1:
    mid = (yes + no)//2
    if check(mid):
        yes = mid
    else:
        no = mid

print(yes)
0