結果
問題 |
No.1607 Kth Maximum Card
|
ユーザー |
![]() |
提出日時 | 2021-07-24 05:54:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,811 ms / 3,500 ms |
コード長 | 750 bytes |
コンパイル時間 | 211 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 125,832 KB |
最終ジャッジ日時 | 2024-07-19 06:13:16 |
合計ジャッジ時間 | 20,693 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
import sys input = sys.stdin.readline from collections import deque N,M,K=map(int,input().split()) E=[[] for i in range(N)] for i in range(M): u,v,c=map(int,input().split()) u-=1 v-=1 E[u].append((v,c)) E[v].append((u,c)) OK=10**6 NG=0 while OK>NG+1: mid=(OK+NG)//2 Q=deque([0]) ANS=[1<<30]*N ANS[0]=0 while Q: x=Q.popleft() for to,c in E[x]: if c>=mid: if ANS[to]>ANS[x]+1: ANS[to]=ANS[x]+1 Q.append(to) else: if ANS[to]>ANS[x]: ANS[to]=ANS[x] Q.appendleft(to) if ANS[N-1]>=K: NG=mid else: OK=mid print(NG)