結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
58,240 KB
testcase_01 AC 40 ms
52,352 KB
testcase_02 AC 41 ms
52,608 KB
testcase_03 AC 41 ms
52,480 KB
testcase_04 AC 41 ms
52,096 KB
testcase_05 AC 41 ms
52,608 KB
testcase_06 AC 43 ms
52,864 KB
testcase_07 AC 42 ms
53,120 KB
testcase_08 AC 42 ms
52,864 KB
testcase_09 AC 42 ms
52,864 KB
testcase_10 RE -
testcase_11 AC 546 ms
258,872 KB
testcase_12 WA -
testcase_13 AC 81 ms
82,272 KB
testcase_14 AC 97 ms
76,544 KB
testcase_15 WA -
testcase_16 AC 550 ms
259,072 KB
testcase_17 WA -
testcase_18 TLE -
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 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

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