結果

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

ソースコード

diff #

#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
  ll n, m, t; cin >> n >> m >> t;
  vector<ll> cnt(n);
  for(int i=0; i<m; i++){
    int a; cin >> a; a--;
    cnt[a]++;
  }
  ll left=0, right=1e9;
  while(right-left>1){
    ll mid=(left+right)/2;
    ll room=0, need=0;
    for(int i=0; i<n; i++){
      if(cnt[i]>=mid){
        need+=cnt[i]-mid;
      }
      else{
        ll p=mid-cnt[i];
        room+=p/t;
      }
    }
    if(need<=room) right=mid;
    else left=mid;
  }
  cout << right << endl;
  return 0;
}
0