結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー hiyokko2hiyokko2
提出日時 2015-01-09 01:30:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 63 ms / 5,000 ms
コード長 1,088 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 94,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 22:52:17
合計ジャッジ時間 1,532 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>

#define PI 3.14159265359

#define INF 99999999;

#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)

#define EPS 1e-10

typedef long long ll;

using namespace std;



/*
class TheKingsArmyDiv2
{
public:
	int getNumber(vector <string> state)
	{

	}
};
*/


int main()
{
	int T, N, L;
	map<int, int> lmap;
	vector<int> vi;
	
	cin >> T;
	rep(i, T)
	{
		cin >> N;
		
		lmap.clear();
		vi.clear();
		
		rep(j, N)
		{
			cin >> L;
			lmap[L]++;
		}
		
		map<int, int>::iterator it = lmap.begin();
		while (it != lmap.end())
		{
			vi.push_back((*it).second);
			it++;
		}
		
		sort(vi.begin(), vi.end(), greater<int>());
		
		int ret = 0;
		while (vi[2] != 0 && vi.size() >= 3)
		{
			vi[0]--; vi[1]--; vi[2]--;
			ret++;
			sort(vi.begin(), vi.end(), greater<int>());
		}
		
		cout << ret << endl;
		
		/*
		REP(vi.size())
		{
			cout << vi[i] << " ";
		}
		*/
	}
	
	return 0;
}
0