結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
|
提出日時 | 2019-08-06 22:54:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 5,000 ms |
コード長 | 643 bytes |
コンパイル時間 | 2,430 ms |
コンパイル使用メモリ | 206,108 KB |
最終ジャッジ日時 | 2025-01-07 10:55:48 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int t;cin>>t; while (t--) { int n;cin>>n; map<int,int> mp; for (int i=0;i<n;i++) { int a;cin>>a; mp[a]++; } vector<int> v; for (auto p:mp) v.push_back(p.second); sort(v.rbegin(), v.rend()); int ans=0; if (v.size() >= 3) { while (v[2]) { ans++; v[0]--; v[1]--; v[2]--; sort(v.rbegin(),v.rend()); } } cout<<ans<<endl; } return 0; }