結果

問題 No.3297 Bake Cookies
ユーザー srjywrdnprkt
提出日時 2025-10-09 17:37:15
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,148 bytes
コンパイル時間 3,236 ms
コンパイル使用メモリ 278,296 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-09 17:37:22
合計ジャッジ時間 6,600 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/modint>

using namespace std;
//using namespace atcoder;
using ll = long long;
//using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    /*
       c(i) = オーブンiで焼くと1分で焼けるクッキーの数
       x分で焼けるか?
       まず、min(x, c(i))個のクッキーを焼く。
       c(i)-x>0ならその分は他のところに回す。
       x-c(i)>0なら余剰があり、(x-c(i))/T個のクッキーを追加で焼ける。
    */

    ll N, M, T;
    cin >> N >> M >> T;
    vector<ll> c(N+1);
    for (int i=1; i<=M; i++){
        ll a;
        cin >> a;
        c[a]++;
    }

    auto check=[&](ll x)->bool{
        ll a=0, b=0; //a:残りのクッキー、b:余剰で焼けるクッキーの数
        for (int i=1; i<=N; i++){
            if (c[i]-x>0) a += c[i]-x;
            else if (x-c[i]>0) b += (x-c[i])/T;
        }
        return a<=b;
    };
    ll l=0, r=M, mid;
    while(r-l>1){
        mid = (l+r)/2;
        if (check(mid)) r=mid;
        else l=mid;
    }
    cout << r << endl;

    return 0;
}
0