結果

問題 No.1607 Kth Maximum Card
ユーザー rlangevinrlangevin
提出日時 2023-10-04 12:07:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,747 ms / 3,500 ms
コード長 955 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 136,424 KB
最終ジャッジ日時 2023-10-04 12:08:12
合計ジャッジ時間 20,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
71,540 KB
testcase_01 AC 89 ms
71,712 KB
testcase_02 AC 90 ms
71,852 KB
testcase_03 AC 90 ms
71,728 KB
testcase_04 AC 89 ms
71,668 KB
testcase_05 AC 91 ms
71,712 KB
testcase_06 AC 90 ms
71,756 KB
testcase_07 AC 89 ms
71,596 KB
testcase_08 AC 1,390 ms
133,492 KB
testcase_09 AC 359 ms
108,212 KB
testcase_10 AC 473 ms
114,268 KB
testcase_11 AC 172 ms
87,408 KB
testcase_12 AC 361 ms
105,040 KB
testcase_13 AC 277 ms
84,832 KB
testcase_14 AC 354 ms
90,824 KB
testcase_15 AC 897 ms
118,664 KB
testcase_16 AC 149 ms
83,404 KB
testcase_17 AC 195 ms
82,916 KB
testcase_18 AC 717 ms
104,316 KB
testcase_19 AC 532 ms
96,440 KB
testcase_20 AC 583 ms
98,048 KB
testcase_21 AC 695 ms
100,148 KB
testcase_22 AC 1,099 ms
133,204 KB
testcase_23 AC 1,258 ms
136,424 KB
testcase_24 AC 682 ms
94,324 KB
testcase_25 AC 371 ms
90,292 KB
testcase_26 AC 444 ms
89,808 KB
testcase_27 AC 643 ms
93,868 KB
testcase_28 AC 566 ms
90,936 KB
testcase_29 AC 303 ms
97,500 KB
testcase_30 AC 1,747 ms
129,892 KB
testcase_31 AC 1,178 ms
108,664 KB
testcase_32 AC 305 ms
98,824 KB
testcase_33 AC 306 ms
98,636 KB
testcase_34 AC 456 ms
98,968 KB
testcase_35 AC 316 ms
98,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

from collections import *
def check(m):
    Q = deque()
    inf = 10 ** 18
    dist = [inf] * N
    dist[0] = 0
    Q.append(0)
    while Q:
        u = Q.popleft()
        for v, cost in G[u]:
            if dist[u] >= K and dist[u] != inf:
                return dist[-1] < K
            c = int(cost > m)
            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