結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  TLwiegehtt | 
| 提出日時 | 2015-07-13 15:10:02 | 
| 言語 | C90 (gcc 12.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 904 bytes | 
| コンパイル時間 | 306 ms | 
| コンパイル使用メモリ | 22,016 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-08 06:56:28 | 
| 合計ジャッジ時間 | 1,057 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 4 | 
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d", &t);
      |         ^~~~~~~~~~~~~~~
main.c:19:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |                 scanf("%d", &n);
      |                 ^~~~~~~~~~~~~~~
main.c:22:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |                         scanf("%d", &L[i]);
      |                         ^~~~~~~~~~~~~~~~~~
            
            ソースコード
#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;
}
            
            
            
        