結果

問題 No.3297 Bake Cookies
ユーザー norioc
提出日時 2025-10-05 16:12:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 462 ms / 2,000 ms
コード長 821 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 113,448 KB
最終ジャッジ日時 2025-10-05 16:13:11
合計ジャッジ時間 11,464 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

def bsearch(low: int, high: int, pred, is_complement=False) -> int:
    def test(x: int) -> bool:
        return not pred(x) if is_complement else pred(x)

    assert test(low)
    lo = low
    hi = high
    res = low
    while lo <= hi:
        m = (lo + hi) // 2
        if test(m):
            res = max(res, m)
            lo = m + 1
        else:
            hi = m - 1

    return res + 1 if is_complement else res


INF = 1 << 60
N, M, T = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))


def can(t: int) -> bool:
    xs = [0] * N
    cnt = 0
    for a in A:
        if xs[a] < t:
            xs[a] += 1
        else:
            cnt += 1

    d = 0
    for i in range(N):
        d += (t - xs[i]) // T

    return cnt <= d


res = bsearch(0, INF, can, is_complement=True)
print(res)
0