結果

問題 No.1607 Kth Maximum Card
ユーザー rlangevinrlangevin
提出日時 2023-10-04 12:16:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,614 ms / 3,500 ms
コード長 951 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 87,340 KB
実行使用メモリ 138,084 KB
最終ジャッジ日時 2023-10-04 12:16:53
合計ジャッジ時間 19,516 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,780 KB
testcase_01 AC 89 ms
71,860 KB
testcase_02 AC 91 ms
71,740 KB
testcase_03 AC 90 ms
71,748 KB
testcase_04 AC 92 ms
71,832 KB
testcase_05 AC 92 ms
71,696 KB
testcase_06 AC 90 ms
71,708 KB
testcase_07 AC 104 ms
71,572 KB
testcase_08 AC 1,392 ms
134,316 KB
testcase_09 AC 358 ms
108,108 KB
testcase_10 AC 441 ms
113,976 KB
testcase_11 AC 193 ms
87,360 KB
testcase_12 AC 342 ms
105,028 KB
testcase_13 AC 271 ms
84,972 KB
testcase_14 AC 321 ms
90,192 KB
testcase_15 AC 931 ms
119,844 KB
testcase_16 AC 149 ms
83,404 KB
testcase_17 AC 196 ms
83,020 KB
testcase_18 AC 660 ms
105,876 KB
testcase_19 AC 504 ms
97,096 KB
testcase_20 AC 573 ms
98,836 KB
testcase_21 AC 613 ms
101,120 KB
testcase_22 AC 1,004 ms
136,488 KB
testcase_23 AC 1,186 ms
138,084 KB
testcase_24 AC 609 ms
94,096 KB
testcase_25 AC 350 ms
90,376 KB
testcase_26 AC 433 ms
89,876 KB
testcase_27 AC 614 ms
94,588 KB
testcase_28 AC 479 ms
91,184 KB
testcase_29 AC 320 ms
97,116 KB
testcase_30 AC 1,614 ms
132,744 KB
testcase_31 AC 1,098 ms
109,840 KB
testcase_32 AC 292 ms
98,572 KB
testcase_33 AC 301 ms
98,744 KB
testcase_34 AC 417 ms
98,772 KB
testcase_35 AC 306 ms
98,836 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()
        d = dist[u]
        for v, cost in G[u]:
            if d >= K and d != inf:
                return dist[-1] < K
            c = int(cost > m)
            if dist[v] <= d + c:
                continue
            dist[v] = d + 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