結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー CleyLCleyL
提出日時 2021-12-12 11:14:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 675 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 02:59:57
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
int main(){
    int t;cin>>t;
    for(int i = 0; t > i; i++){
        int n;cin>>n;
        map<int,int> A;
        vector<int> B(n);
        priority_queue<int> C;
        for(int i = 0; n > i; i++){
            cin>>B[i];
            A[B[i]]++;
        }
        
        for(auto x: A){
          C.push(x.second);
        }
        int ans = 0;
        while(C.size() > 2){
          int x = C.top();C.pop();
          int y = C.top();C.pop();
          int z = C.top();C.pop();
          ans += z;
          C.push(x-z);C.push(y-z);
        }
        cout << ans << endl;
    }
}
0