結果

問題 No.2182 KODOKU Stone
ユーザー 👑 rin204rin204
提出日時 2023-12-29 15:43:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 951 ms / 2,000 ms
コード長 949 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 160,944 KB
最終ジャッジ日時 2023-12-29 15:43:54
合計ジャッジ時間 16,077 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 43 ms
59,332 KB
testcase_03 AC 41 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 38 ms
53,460 KB
testcase_06 AC 48 ms
61,596 KB
testcase_07 AC 51 ms
63,780 KB
testcase_08 AC 49 ms
61,596 KB
testcase_09 AC 66 ms
61,596 KB
testcase_10 AC 38 ms
53,460 KB
testcase_11 AC 897 ms
160,944 KB
testcase_12 AC 916 ms
154,256 KB
testcase_13 AC 127 ms
88,844 KB
testcase_14 AC 133 ms
77,324 KB
testcase_15 AC 951 ms
146,164 KB
testcase_16 AC 910 ms
160,688 KB
testcase_17 AC 120 ms
87,400 KB
testcase_18 AC 832 ms
146,080 KB
testcase_19 AC 443 ms
99,868 KB
testcase_20 AC 670 ms
126,708 KB
testcase_21 AC 207 ms
78,108 KB
testcase_22 AC 142 ms
76,792 KB
testcase_23 AC 364 ms
91,708 KB
testcase_24 AC 249 ms
82,468 KB
testcase_25 AC 100 ms
76,536 KB
testcase_26 AC 95 ms
76,664 KB
testcase_27 AC 109 ms
76,664 KB
testcase_28 AC 635 ms
119,460 KB
testcase_29 AC 788 ms
136,528 KB
testcase_30 AC 824 ms
147,648 KB
testcase_31 AC 647 ms
118,744 KB
testcase_32 AC 608 ms
114,964 KB
testcase_33 AC 744 ms
130,176 KB
testcase_34 AC 233 ms
79,908 KB
testcase_35 AC 741 ms
129,140 KB
testcase_36 AC 225 ms
79,948 KB
testcase_37 AC 852 ms
146,344 KB
testcase_38 AC 38 ms
53,460 KB
testcase_39 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
K = list(map(int, input().split()))
A = [[] for _ in range(n)]
for i in range(n):
    input()
    A[i] = list(map(int, input().split()))


def ok(x):
    C = []
    all_ = []
    for row in A:
        c = sum(a >= x for a in row)
        if c == len(row):
            all_.append(c)
        else:
            C.append(c)

    if not C:
        return True
    C.sort()
    all_.sort(reverse=True)
    cp = len(C) - 1
    cc = 0
    for k in K[::-1]:
        if C and C[cp + min(cc, len(all_))] >= k:
            return True
        elif all_ and all_[0] >= k:
            return True

        if C[cp] == k - 1:
            cp -= 1
            cc += 1
        elif all_:
            all_.pop()
        else:
            return False

        if cp < 0 and all_:
            return True

    return False


l = 1
r = 1 << 30
while r - l > 1:
    mid = (l + r) // 2
    if ok(mid):
        l = mid
    else:
        r = mid

print(l)
0