結果

問題 No.3297 Bake Cookies
コンテスト
ユーザー norioc
提出日時 2025-10-05 16:12:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 309 ms / 2,000 ms
+ 89µs
コード長 821 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 486 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 121,008 KB
最終ジャッジ日時 2026-07-15 13:47:01
合計ジャッジ時間 9,284 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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