結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー TLwiegehttTLwiegehtt
提出日時 2015-07-13 15:10:02
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 24,432 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 15:22:19
合計ジャッジ時間 1,704 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int compare_int( const void*a, const void*b){
	int ta = *(int*)a;
	int tb = *(int*)b;
	return ta - tb; // tb-taだと降順
}

int main(void){
	int t;
	scanf("%d", &t);
	
	for(;t>0;t--){
		int i,n;
		int cnt=0;
		int L[110];
		
		scanf("%d", &n);
		
		for(i=0;i<n;i++){
			scanf("%d", &L[i]);
		}
		
		qsort(L, n, sizeof(int), compare_int);
		
		
		while(1){
			int a=0,b=0,c=0;
			int ap=-1,bp=-1,cp=-1;
			
			for(i=0;i<n;i++){
				if( a==0 && L[i] != 0 ){
					a = L[i];
					ap = i;
					continue;
				}
				
				if(b==0 && L[i] != 0 && L[i] != a){
					b = L[i];
					bp = i;
					continue;
				}
				
				if(c==0 && L[i] != 0 && L[i] != a && L[i] != b){
					c = L[i];
					cp = i;
					continue;
				}
			}
			
			if(c != 0){
				L[ap] = 0;
				L[bp] = 0;
				L[cp] = 0;
				cnt++;
			}else{
				break;
			}
		}
		
		printf("%d\n", cnt);
	}
	
	
	return 0;
}
0