結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー erieri
提出日時 2015-08-02 02:43:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 75,472 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 00:30:17
合計ジャッジ時間 1,453 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
4,380 KB
testcase_01 AC 50 ms
4,376 KB
testcase_02 AC 27 ms
4,376 KB
testcase_03 AC 52 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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) x[i] = pq.top(), pq.pop();
			REP(i, 3) if (x[i] > 1) pq.push(x[i] - 1);
		}
		cout << ans << endl;
	}
	return 0;
}
0