結果

問題 No.3297 Bake Cookies
コンテスト
ユーザー yuunegi
提出日時 2026-01-23 17:53:40
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 63 ms / 2,000 ms
コード長 778 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,360 ms
コンパイル使用メモリ 335,028 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-23 17:53:47
合計ジャッジ時間 7,238 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,t;
    cin>>n>>m>>t;
    int a[n];
    for(int i=0;i<n;i++){
        a[i]=0;
    }
    for(int i=0;i<m;i++){
        int b;
        cin>>b;
        b--;
        a[b]++;
    }
    int maxs=0,mins=1;
    for(int i=0;i<n;i++){
        maxs=max(a[i],maxs);
    }
    if(t>=maxs){
        cout<<maxs<<endl;
        return 0;
    }
    while(mins!=maxs){
        int next=(maxs+mins)/2;
        int tmp=0;
        for(int i=0;i<n;i++){
            if(a[i]>next){
                tmp+=a[i]-next;
            }else{
                tmp-=(next-a[i])/t;
            }
        }
        if(tmp>0){
            mins=next+1;
        }else{
            maxs=next;
        }
    }
    cout<<maxs<<endl;
    return 0;
}
0