結果
問題 |
No.2182 KODOKU Stone
|
ユーザー |
|
提出日時 | 2022-09-21 01:18:24 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,369 bytes |
コンパイル時間 | 358 ms |
コンパイル使用メモリ | 82,212 KB |
実行使用メモリ | 339,212 KB |
最終ジャッジ日時 | 2024-11-14 12:04:06 |
合計ジャッジ時間 | 32,539 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 2 RE * 2 TLE * 8 |
ソースコード
import sys input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 n = ii() k = [i - 1 for i in li()][::-1] a = [] for _ in range(n): _ = ii() a.append(list(sorted(li(), reverse=True))) def check(x, s, ix): for i in s: if len(a[i]) > k[ix] and a[i][k[ix]] >= x: return True if len(a[i]) - 1 > k[ix] and k[ix] - 1 >= 0 and a[i][k[ix] - 1] >= x and ix + 1 < len(k): s.discard(i) ix += 1 p = check(x, s, ix) ix -= 1 s.add(i) if p: return True if len(a[i]) == k[ix] and a[i][min(len(a[i]) - 1, k[ix])] >= x: s.discard(i) ix += 1 p = check(a[i][min(len(a[i]) - 1, k[ix])], s, ix) s.add(i) ix -= 1 if p: return True if len(a[i]) < k[ix] and a[i][min(len(a[i]) - 1, k[ix])] >= x: s.discard(i) ix += 1 p = check(x, s, ix) s.add(i) ix -= 1 if p: return True return False ok = 0 ng = 10 ** 9 + 1 while abs(ok - ng) > 1: mid = (ok + ng) // 2 if check(mid, set(range(n)), 0): ok = mid else: ng = mid print(ok)