結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー erieri
提出日時 2015-08-02 02:39:25
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 75,760 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-25 00:30:14
合計ジャッジ時間 7,280 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<map>
#include<queue>
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;
int main(){
	int t; cin >> t;
	while (t--){
		map<int, int> mp;
		int n; cin >> n;
		REP(i,n){
			int l; cin >> l;
			mp[l]++;
		}
		priority_queue<int> pq;
		for (auto it : mp) pq.push(it.second);
		int ans = 0;
		while (pq.size() >= 3){
			ans++;
			int x[3];
			REP(i, 3) pq.top(), pq.pop();
			REP(i, 3) if (x[i] > 1) pq.push(x[i] - 1);
		}
		cout << ans << endl;
	}
	return 0;
}
0