結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー IL_mstaIL_msta
提出日時 2015-06-30 20:20:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,287 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 88,340 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-22 04:43:57
合計ジャッジ時間 1,498 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
    
    int T,N,L[100],num[100],count,ans[1000];
	cin>>T;

	for(int Loop=0;Loop<T;++Loop){
		cin>>N;
		rep(i,N){
			cin>>L[i];
		}
		sort(L,L+N);
		count=0;
		rep(i,N){
			num[i]=0;
		}
		rep(i,N){
			if(i==0){
				++num[count];
			}else{
				if(L[i] != L[i-1]){
					++count;
				}
				++num[count];
			}
		}
		sort(num,num+count+1,greater<int>());
		ans[Loop]=0;
		for(int ka=0;3*ka < N;++ka)
		{
			int i,j,k;
			for(i=  0;i<count+1;++i){if(num[i]>0)break;}
			for(j=i+1;j<count+1;++j){if(num[j]>0)break;}
			for(k=j+1;k<count+1;++k){if(num[k]>0)break;}
			if( i<count+1 && j<count+1 && k<count+1){
				--num[i];
				--num[j];
				--num[k];
				++ans[Loop];
			}
		}
	}

	rep(i,T){
		P(ans[i]);
	}
    
    return 0;
}
0