結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-08-18 15:17:41 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 27 ms / 5,000 ms | 
| コード長 | 494 bytes | 
| コンパイル時間 | 2,350 ms | 
| コンパイル使用メモリ | 203,092 KB | 
| 最終ジャッジ日時 | 2025-01-13 03:07:40 | 
| ジャッジサーバーID (参考情報) | judge5 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 4 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int t; cin>>t;
	for(int i=0;i<t;++i){
		int n; cin>>n;
		unordered_map<int,int>m;
		for(int j=0;j<n;++j){
			int l; cin>>l;
			++m[l];
		}
		priority_queue<int>q;
		for(auto&&j:m)q.push({j.second});
		int ans=0;
		while(q.size()>2){
			vector<int>abc(3);
			for(auto&&j:abc){
				j=q.top(); q.pop();
			}
			++ans;
			for(auto&&j:abc){
				if(j>1)q.push(j-1);
			}
		}
		cout<<ans<<"\n"s;
	}
}
            
            
            
        