結果
| 問題 |
No.1607 Kth Maximum Card
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-07 11:18:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 778 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 82,296 KB |
| 実行使用メモリ | 167,724 KB |
| 最終ジャッジ日時 | 2024-07-22 04:47:17 |
| 合計ジャッジ時間 | 14,302 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 2 -- * 25 |
ソースコード
N,M,K = map(int,input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
a,b,c = map(int,input().split())
G[a].append((b,c))
G[b].append((a,c))
import heapq
inf = 10 ** 6
def calc(x):
dist = [inf] * (N+1)
dist[1] = 0
q = [(0,1)]
while q:
d,now = heapq.heappop(q)
if now == N:break
if dist[now] < d:
continue
for v,c in G[now]:
if c > x:
c = 1
else:
c = 0
if dist[v] > d + c:
dist[v] = d + c
heapq.heappush(q,(d+c,v))
return dist[N] < K
start = -1
end = 2 * 10 ** 5
while end - start > 1:
mid = (end + start) // 2
if calc(mid):
end = mid
else:
start = mid
print(end)