結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  nenuon | 
| 提出日時 | 2017-07-17 00:52:20 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 57 ms / 5,000 ms | 
| コード長 | 666 bytes | 
| コンパイル時間 | 2,103 ms | 
| コンパイル使用メモリ | 179,788 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-08 04:43:21 | 
| 合計ジャッジ時間 | 2,537 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 4 | 
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
int main(){
	int T;
	cin >> T;
	REP(i,0,T){
		int N;
		cin >> N;
		vector<int> L(N);
		ll sum = 0;
		map<int, int> m;
		REP(i,0,N){
			cin >> L[i];
			sum += L[i];
			m[L[i]]++;
		}
		priority_queue<int> pq;
		for (auto i : m){
			pq.push(i.second);
		}
		int ans = 0;
		if (m.size() >= 3){
			while (1){
				int a = pq.top(); pq.pop();
				int b = pq.top(); pq.pop();
				int c = pq.top(); pq.pop();
				if (c <= 0)	break;
				ans++;
				pq.push(a - 1);
				pq.push(b - 1);
				pq.push(c - 1);
			}
		}
		p(ans);
	}
}
            
            
            
        