結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー | 👑 | 
| 提出日時 | 2021-12-12 11:14:03 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 675 bytes | 
| コンパイル時間 | 874 ms | 
| コンパイル使用メモリ | 86,952 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-20 21:39:07 | 
| 合計ジャッジ時間 | 1,843 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 4 | 
ソースコード
#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;
    }
}
            
            
            
        