結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー cureskolcureskol
提出日時 2020-03-28 13:27:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 404 bytes
コンパイル時間 1,912 ms
コンパイル使用メモリ 172,692 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 17:37:25
合計ジャッジ時間 3,077 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
4,380 KB
testcase_01 AC 49 ms
4,380 KB
testcase_02 AC 26 ms
4,380 KB
testcase_03 AC 50 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

signed main(){
  int q;cin>>q;
  while(q--){
    int n;cin>>n;
    map<int,int> m;
    while(n--){
      int a;cin>>a;m[a]++;
    }
    vector<int> v;
    for(auto p:m)v.push_back(p.second);
    int l=0,r=1e9;
    while(r-l>1){
      int mid=(r+l)>>1;
      int a=0;
      for(int p:v)a+=min(mid,p);
      (a>=mid*3?l:r)=mid;
    }
    cout<<l<<endl;
  }
}
0