結果

問題 No.3297 Bake Cookies
ユーザー Iroha_3856
提出日時 2025-10-05 15:20:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 2,074 bytes
コンパイル時間 5,279 ms
コンパイル使用メモリ 351,992 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-05 15:20:37
合計ジャッジ時間 7,485 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = atcoder::modint998244353;
// using mint = double;

//PBDS-tree
#if __has_include(<ext/pb_ds/assoc_container.hpp>)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//tree.find_by_order(k) = tree[k] (0-indexed)
//tree.order_of_key(k) = tree.lower_bound(k) - tree.begin()
//Note: Can only be used for non-multiple sets.
#endif

#define rep(i, l, r) for (int i = (int)(l); i<(int)(r); i++)
#define ll long long
#define ld long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define siz(x) (int)(x).size()

template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int inf = 1e9;
const ll INF = 4e18;

template<class T> using pq = priority_queue<T, vector<T>, less<T>>;
template<class T> using spq = priority_queue<T, vector<T>, greater<T>>;

vector<int> di = {0, 0, 1, -1};
vector<int> dj = {1, -1, 0, 0};

struct Edge {
    int to, cost;
};

void solve() {
    int N, M, T; cin >> M >> N >> T;
    vector<int> C(M, 0);
    rep(i, 0, N) {
        int a; cin >> a;
        C[a-1]++;
    }

    auto isok = [&](int x) -> bool {
        int cnt = 0;
        rep(i, 0, M) {
            if (C[i] > x) cnt += C[i] - x;
        }
        int v = 0;
        rep(i, 0, M) {
            if (C[i] <= x) v += (x - C[i]) / T;
        }
        if (cnt <= v) return true;
        return false;
    };

    int ok = N, ng = 0;
    while(ok-ng>1) {
        int mid = (ok + ng) / 2;
        if (isok(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
}
0