結果

問題 No.2182 KODOKU Stone
ユーザー ShirotsumeShirotsume
提出日時 2022-09-21 01:25:46
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,611 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 259,056 KB
最終ジャッジ日時 2024-04-26 21:06:03
合計ジャッジ時間 7,876 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,864 KB
testcase_01 AC 43 ms
52,224 KB
testcase_02 AC 40 ms
52,736 KB
testcase_03 AC 38 ms
52,352 KB
testcase_04 AC 38 ms
52,352 KB
testcase_05 AC 40 ms
52,096 KB
testcase_06 RE -
testcase_07 AC 39 ms
52,992 KB
testcase_08 RE -
testcase_09 AC 40 ms
52,608 KB
testcase_10 RE -
testcase_11 AC 541 ms
258,492 KB
testcase_12 RE -
testcase_13 AC 79 ms
82,676 KB
testcase_14 AC 90 ms
76,496 KB
testcase_15 RE -
testcase_16 AC 554 ms
259,056 KB
testcase_17 WA -
testcase_18 RE -
testcase_19 AC 271 ms
146,332 KB
testcase_20 AC 638 ms
229,356 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 71 ms
76,000 KB
testcase_26 AC 73 ms
75,904 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 336 ms
238,060 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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
rec = True
if rec:
    sys.setrecursionlimit(5 * 10 ** 5)
    from pypyjit import set_param
    set_param('max_unroll_recursion=-1')
 
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):
            if k[ix] > k[ix + 1]:
                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:
            if k[ix] > k[ix + 1]:
                s.discard(i)
                ix += 1
                p = check(x, s, ix)
                ix -= 1
                s.add(i)
            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)
0