結果

問題 No.1607 Kth Maximum Card
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-07-17 10:34:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,599 ms / 3,500 ms
コード長 734 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 191,400 KB
最終ジャッジ日時 2023-09-21 03:32:09
合計ジャッジ時間 32,082 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,744 KB
testcase_01 AC 96 ms
71,936 KB
testcase_02 AC 96 ms
71,544 KB
testcase_03 AC 96 ms
71,588 KB
testcase_04 AC 96 ms
71,596 KB
testcase_05 AC 95 ms
71,552 KB
testcase_06 AC 96 ms
71,596 KB
testcase_07 AC 95 ms
71,972 KB
testcase_08 AC 1,795 ms
153,016 KB
testcase_09 AC 2,052 ms
165,056 KB
testcase_10 AC 2,599 ms
191,400 KB
testcase_11 AC 565 ms
93,000 KB
testcase_12 AC 2,005 ms
163,580 KB
testcase_13 AC 329 ms
85,320 KB
testcase_14 AC 368 ms
87,964 KB
testcase_15 AC 1,136 ms
121,464 KB
testcase_16 AC 314 ms
85,628 KB
testcase_17 AC 218 ms
80,488 KB
testcase_18 AC 832 ms
107,828 KB
testcase_19 AC 535 ms
94,652 KB
testcase_20 AC 733 ms
100,624 KB
testcase_21 AC 709 ms
102,564 KB
testcase_22 AC 1,346 ms
138,644 KB
testcase_23 AC 1,375 ms
138,988 KB
testcase_24 AC 783 ms
95,996 KB
testcase_25 AC 470 ms
87,620 KB
testcase_26 AC 596 ms
91,136 KB
testcase_27 AC 833 ms
96,732 KB
testcase_28 AC 682 ms
92,312 KB
testcase_29 AC 1,326 ms
119,608 KB
testcase_30 AC 1,935 ms
131,544 KB
testcase_31 AC 1,278 ms
115,676 KB
testcase_32 AC 436 ms
102,844 KB
testcase_33 AC 434 ms
103,076 KB
testcase_34 AC 522 ms
103,804 KB
testcase_35 AC 438 ms
102,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n,m,k = map(int,input().split())
e = [[] for i in range(n)]
for _ in range(m):
    u,v,c = map(int,input().split())
    u -= 1
    v -= 1
    e[u].append((v,c))
    e[v].append((u,c))

def search(x):
    dis = [k+1]*n
    dis[0] = 0
    q = deque([[0,0]])
    while q:
        now,cost = q.popleft()
        for nex,c in e[now]:
            d = int(c > x)
            if dis[nex] > cost + d:
                dis[nex] = cost+d
                if d:
                    q.append([nex,cost+d])
                else:
                    q.appendleft([nex,cost])
    return dis[-1] < k


l = -1
r = 2*10**5+5

while r > l + 1:
    m = (r+l)//2
    if search(m):
        r = m
    else:
        l = m
print(r)
0