結果
問題 | No.1607 Kth Maximum Card |
ユーザー | mkawa2 |
提出日時 | 2023-02-24 13:59:11 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,984 ms / 3,500 ms |
コード長 | 1,568 bytes |
コンパイル時間 | 239 ms |
コンパイル使用メモリ | 82,524 KB |
実行使用メモリ | 149,772 KB |
最終ジャッジ日時 | 2024-09-12 21:43:38 |
合計ジャッジ時間 | 21,022 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
54,792 KB |
testcase_01 | AC | 40 ms
55,960 KB |
testcase_02 | AC | 40 ms
55,244 KB |
testcase_03 | AC | 39 ms
55,092 KB |
testcase_04 | AC | 40 ms
56,044 KB |
testcase_05 | AC | 41 ms
55,668 KB |
testcase_06 | AC | 40 ms
54,848 KB |
testcase_07 | AC | 40 ms
54,240 KB |
testcase_08 | AC | 1,079 ms
123,552 KB |
testcase_09 | AC | 782 ms
114,380 KB |
testcase_10 | AC | 1,984 ms
149,772 KB |
testcase_11 | AC | 174 ms
87,608 KB |
testcase_12 | AC | 1,147 ms
117,456 KB |
testcase_13 | AC | 191 ms
83,252 KB |
testcase_14 | AC | 214 ms
85,180 KB |
testcase_15 | AC | 949 ms
117,880 KB |
testcase_16 | AC | 204 ms
83,884 KB |
testcase_17 | AC | 113 ms
78,476 KB |
testcase_18 | AC | 602 ms
98,772 KB |
testcase_19 | AC | 395 ms
91,160 KB |
testcase_20 | AC | 513 ms
95,108 KB |
testcase_21 | AC | 542 ms
96,116 KB |
testcase_22 | AC | 907 ms
130,260 KB |
testcase_23 | AC | 914 ms
130,248 KB |
testcase_24 | AC | 432 ms
90,512 KB |
testcase_25 | AC | 242 ms
85,920 KB |
testcase_26 | AC | 327 ms
88,308 KB |
testcase_27 | AC | 464 ms
91,524 KB |
testcase_28 | AC | 378 ms
88,988 KB |
testcase_29 | AC | 1,051 ms
109,876 KB |
testcase_30 | AC | 1,602 ms
126,576 KB |
testcase_31 | AC | 1,000 ms
104,208 KB |
testcase_32 | AC | 228 ms
105,416 KB |
testcase_33 | AC | 205 ms
102,064 KB |
testcase_34 | AC | 256 ms
105,072 KB |
testcase_35 | AC | 285 ms
105,292 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 md = 10**9+7 # md = 998244353 from collections import deque n, m, k = LI() to = [[] for _ in range(n)] for _ in range(m): u, v, c = LI1() c += 1 to[u].append((v, c)) to[v].append((u, c)) def binary_search(l, r, minimize): if minimize: l -= 1 else: r += 1 while l+1 < r: m = (l+r)//2 if ok(m) ^ minimize: l = m else: r = m if minimize: return r return l def ok(m): q = deque([0]) dist = [inf]*n dist[0] = 0 while q: u = q.popleft() if dist[u] >= k: return False for v, c in to[u]: nd = dist[u]+(c > m) if nd >= dist[v]: continue dist[v] = nd if c > m: q.append(v) else: q.appendleft(v) if dist[-1] < k: return True return False print(binary_search(0, 200000, True))