結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using ll=long long;
using P=pair<ll,int>;
P op(P x,P y){
	return min(x,y);
}
P e(){
	return make_pair(1e18,-1);
}
int main(){
	int n,m;
	ll t;
	cin>>n>>m>>t;
	vector<int> a(n);
	for(int i=0;i<m;i++){
		int tmp;
		cin>>tmp;
		tmp--;
		a[tmp]++;
	}
	atcoder::segtree<P,op,e> st(n);
	for(int i=0;i<n;i++)st.set(i,make_pair(a[i],i));
	priority_queue<P> pq;
	for(int i=0;i<n;i++)pq.push(make_pair(a[i],i));
	ll ans;
	while(1){
		auto[x,i]=pq.top();
		pq.pop();
		auto[y,j]=st.prod(0,n);
		if(y+t>=x-1){
			ans=x;
			break;
		}
		x--;
		y+=t;
		pq.push(make_pair(x,i));
		st.set(j,make_pair(y,j));
	}
	cout<<ans<<endl;
}


0