結果
問題 | No.1607 Kth Maximum Card |
ユーザー | horitaka1999 |
提出日時 | 2021-12-11 00:29:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,190 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 87,040 KB |
実行使用メモリ | 380,568 KB |
最終ジャッジ日時 | 2023-09-26 01:51:31 |
合計ジャッジ時間 | 7,777 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
71,616 KB |
testcase_01 | AC | 94 ms
71,640 KB |
testcase_02 | AC | 96 ms
71,348 KB |
testcase_03 | AC | 95 ms
71,344 KB |
testcase_04 | AC | 96 ms
71,592 KB |
testcase_05 | AC | 94 ms
71,568 KB |
testcase_06 | AC | 95 ms
71,560 KB |
testcase_07 | AC | 97 ms
71,560 KB |
testcase_08 | TLE | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
N,M,K = map(int,input().split()) board = [] for _ in range(M): u,v,c = map(int,input().split()) u-=1 v-=1 board.append((u,v,c)) from collections import deque #edge[a].append((b,cost)) def bfs(st,dis,edge): q = deque() dis[st] = 0 q.append((0,st)) while q: t,now = q.popleft() if t > dis[now]: continue for next,cost in edge[now]: if dis[next] > cost + dis[now]: dis[next] = cost + dis[now] if cost == 0: q.appendleft((dis[next],next)) else: q.append((dis[next],next)) def is_ok(x): edge = [[] for _ in range(N)] for i in range(M): u,v,c = board[i] if c > x: edge[u].append((v,1)) edge[v].append((u,1)) else: edge[u].append((v,0)) edge[v].append((u,0)) INF = float('inf') dis = [INF for _ in range(N)] bfs(0,dis,edge) if dis[N-1] <= K -1: return True else: return False ok = 2 * 10 ** 5 ng = -1 while ok - ng > 1: x = (ng+ok)//2 if is_ok(x): ok = x else: ng = x print(ok)