結果

問題 No.1607 Kth Maximum Card
ユーザー H3PO4H3PO4
提出日時 2023-03-31 13:59:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 2,423 ms / 3,500 ms
コード長 823 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 81,488 KB
実行使用メモリ 141,976 KB
最終ジャッジ日時 2023-10-24 01:29:26
合計ジャッジ時間 30,010 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,536 KB
testcase_01 AC 47 ms
55,536 KB
testcase_02 AC 48 ms
55,536 KB
testcase_03 AC 44 ms
55,536 KB
testcase_04 AC 45 ms
55,536 KB
testcase_05 AC 44 ms
55,536 KB
testcase_06 AC 44 ms
55,536 KB
testcase_07 AC 44 ms
55,536 KB
testcase_08 AC 2,423 ms
135,808 KB
testcase_09 AC 1,875 ms
125,752 KB
testcase_10 AC 2,422 ms
141,976 KB
testcase_11 AC 458 ms
87,352 KB
testcase_12 AC 1,812 ms
123,152 KB
testcase_13 AC 245 ms
83,276 KB
testcase_14 AC 276 ms
84,804 KB
testcase_15 AC 1,121 ms
120,112 KB
testcase_16 AC 236 ms
82,800 KB
testcase_17 AC 140 ms
78,000 KB
testcase_18 AC 688 ms
100,696 KB
testcase_19 AC 425 ms
90,916 KB
testcase_20 AC 626 ms
95,332 KB
testcase_21 AC 639 ms
95,568 KB
testcase_22 AC 1,407 ms
134,312 KB
testcase_23 AC 1,193 ms
129,688 KB
testcase_24 AC 658 ms
90,992 KB
testcase_25 AC 414 ms
85,712 KB
testcase_26 AC 495 ms
87,156 KB
testcase_27 AC 711 ms
92,068 KB
testcase_28 AC 556 ms
88,292 KB
testcase_29 AC 1,270 ms
106,968 KB
testcase_30 AC 2,333 ms
132,812 KB
testcase_31 AC 1,299 ms
104,812 KB
testcase_32 AC 301 ms
92,920 KB
testcase_33 AC 296 ms
92,908 KB
testcase_34 AC 388 ms
93,724 KB
testcase_35 AC 282 ms
92,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque

input = sys.stdin.buffer.readline

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

INF = 2 * 10 ** 5 + 1


def is_possible(m: int):
    d = deque([0])
    dist = [INF] * N
    dist[0] = 0
    while d:
        v = d.pop()
        for x, c in G[v]:
            dx = dist[v]
            if c >= m: dx += 1

            if dist[x] <= dx:
                continue
            dist[x] = dx
            if c >= m:
                d.appendleft(x)
            else:
                d.append(x)
    return dist[N - 1] < K


l, r = 0, INF
while r - l > 1:
    m = (r + l) // 2
    if is_possible(m):
        r = m
    else:
        l = m
print(l)
0