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