結果

問題 No.3297 Bake Cookies
ユーザー Carpenters-Cat
提出日時 2025-10-10 23:04:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 195,380 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-10 23:04:30
合計ジャッジ時間 5,996 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main () {
	int N, M; ll T;
	cin >> N >> M >> T;
	std::vector<int> A(N, 0);
	for (int i = 0; i < M; i ++) {
		int a;
		cin >> a;
		A[--a] ++;
	}
	ll ok = M, ng = 0;
	while (abs(ok - ng) > 1) {
		ll mu = (ok + ng) / 2;
		ll x = 0, y = 0;
		for (auto& a : A) {
			if (a > mu) {
				x += (a - mu);
			} else {
				y += (mu - a) / T;
			}
		}
		if (x <= y) {
			ok = mu;
		} else {
			ng = mu;
		}
	}
	cout << ok << endl;
}
0