結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー 👑 naipianaipia
提出日時 2018-06-20 22:56:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 156,744 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 07:24:58
合計ジャッジ時間 2,147 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    int t,n,in;
    cin >> t;
    for(int i=0;i<t;i++){
        map<int,int> mp;
        vector<int> v;
        cin >> n;
        for(int j=0;j<n;j++) cin>>in,mp[in]++;
        for(auto iter=mp.begin();iter!=mp.end();iter++) v.push_back(iter->second);
        sort(v.begin(),v.end(),greater<int>());
        int cnt=0;
        if(v.size()<3) v.push_back(0),v.push_back(0);
        while(v[0]!=0&&v[1]!=0&&v[2]!=0){
            cnt+=v[2];
            v[0]-=v[2];
            v[1]-=v[2];
            v[2]=0;
            sort(v.begin(),v.end(),greater<int>());
        }
        cout << cnt << endl;
    }

    return 0;
}
0