結果

問題 No.3297 Bake Cookies
コンテスト
ユーザー zjsdut
提出日時 2025-11-28 00:40:42
言語 C++17
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 716 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,763 ms
コンパイル使用メモリ 195,384 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-28 00:40:49
合計ジャッジ時間 6,757 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> cnt(n + 1);
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    auto check = [&](long long x) {
        int a = 0;
        long long b = 0;
        for (int i = 1; i <= n; i++) {
            if (cnt[i] > x)
                a += cnt[i] - x;
            else
                b += (x - cnt[i]) / t;
        }
        return a <= b;
    };
    
    long long ok = (long long) m * t, ng = 0;
    while (ok - ng > 1) {
        long long x = (ok + ng) / 2;
        if (check(x))
            ok = x;
        else
            ng = x;
    }
    cout << ok << '\n';
}
0