結果

問題 No.3297 Bake Cookies
ユーザー dyktr_06
提出日時 2025-07-09 05:43:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 195,288 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-09 05:43:50
合計ジャッジ時間 6,292 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    int n, m, t; cin >> n >> m >> t;
    vector<int> a(m);
    for(int i = 0; i < m; i++){
        cin >> a[i];
        a[i]--;
    }

    int ok = m, ng = 0;
    while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        vector<int> cnt(n);
        int s = 0;
        for(int i = 0; i < m; i++){
            if(cnt[a[i]] < mid){
                cnt[a[i]]++;
            }else{
                s--;
            }
        }
        for(int i = 0; i < n; i++){
            s += (mid - cnt[i]) / t;
        }
        if(s >= 0) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}
0