結果

問題 No.3297 Bake Cookies
ユーザー テナガザル
提出日時 2025-10-05 13:47:45
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 895 ms
コンパイル使用メモリ 109,184 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2025-10-05 13:47:58
合計ジャッジ時間 4,603 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int n, m, t;
    cin >> n >> m >> t;
    vector<int> a(m);
    for (int i = 0; i < m; ++i) cin >> a[i];
    if (n == 1)
    {
        cout << m << endl;
        return 0;
    }
    vector<long long> c(n);
    for (int i = 0; i < m; ++i)
    {
        --a[i];
        ++c[a[i]];
    }
    multiset<int> ms(c.begin(), c.end());
    while (true)
    {
        int ba = *ms.rbegin();
        auto itr = ms.begin();
        int tmp = *itr;
        ms.erase(itr);
        auto ritr = ms.end();
        --ritr;
        ms.erase(ritr);
        ms.insert(tmp + t);
        ms.insert(ba - 1);
        int aa = *ms.rbegin();
        if (ba <= aa)
        {
            cout << ba << endl;
            return 0;
        }
    }
}
0