結果

問題 No.3297 Bake Cookies
ユーザー 👑 loop0919
提出日時 2025-10-05 13:48:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 115,360 KB
最終ジャッジ日時 2025-10-05 13:48:27
合計ジャッジ時間 6,650 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

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

cnt_A = Counter(A)


def is_ok(mid):
    rem = 0
    capacity = 0
    for k, v in cnt_A.items():
        if v > mid:
            rem += v - mid
        else:
            capacity += (mid - v) // T

    return rem <= capacity


ok, ng = 10**18, 0
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2

    if is_ok(mid):
        ok = mid
    else:
        ng = mid

print(ok)
0