結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー kpinkcatkpinkcat
提出日時 2023-10-26 12:37:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,024 bytes
コンパイル時間 2,424 ms
コンパイル使用メモリ 212,976 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-26 12:37:47
合計ジャッジ時間 3,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;


int main(){
    int t;
    cin >> t;
    priority_queue<int> pq;
    for (int i = 0; i < t; i++) {
        int t1, ans = 0, al1 = 0;
        cin >> t1;
        map<int, int> mp;
        for (int j = 0; j < t1; j++){
            int t2;
            cin >> t2;
            mp[t2]++;
        }

        for (auto itr = mp.begin(); itr != mp.end(); itr++){
            pq.push(itr->second);
        }
        while (pq.size() >= 3){
            int a, b, c;
            ans++;
            a = pq.top();
            pq.pop();
            b = pq.top();
            pq.pop();
            c = pq.top();
            pq.pop();
            if (a -1) pq.push(a-1);
            if (b -1) pq.push(b-1);
            if (c -1) pq.push(c-1);            
        }
        cout << ans << endl;
    }
}
0