結果
問題 |
No.120 傾向と対策:門松列(その1)
|
ユーザー |
|
提出日時 | 2019-08-06 22:39:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 680 bytes |
コンパイル時間 | 2,172 ms |
コンパイル使用メモリ | 206,188 KB |
最終ジャッジ日時 | 2025-01-07 10:55:29 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 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]++; } int m=mp.size(); 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[2]-=v[0]; v[1]-=v[0]; v[0]=0; sort(v.rbegin(),v.rend()); } } cout<<ans<<endl; } return 0; }