結果
| 問題 | No.29 パワーアップ | 
| コンテスト | |
| ユーザー |  mono1977 | 
| 提出日時 | 2016-12-01 12:05:32 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 568 bytes | 
| コンパイル時間 | 166 ms | 
| コンパイル使用メモリ | 29,708 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-24 20:59:37 | 
| 合計ジャッジ時間 | 935 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 22 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d %d %d",&a,&b,&c);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include<stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	int item[11]={0};
	int total=0,i;
	int a,b,c;
	
	for(i=0;i<n;i++){
		scanf("%d %d %d",&a,&b,&c);
		item[a]++;
		item[b]++;
		item[c]++;
		total += 3;
	}
	
	int min=total/4; //最低でもこれだけパワーアップできる
	int temp=0;
	
	for(i=1;i<=10;i++){//各アイテムを二個使うパワーアップ
		a=item[i]/2;
		temp += a;
		total-=2*a;
	}
	temp += total/4;//残りアイテム4個使うパワーアップ
	
	if(temp>min){
		printf("%d\n",temp);
	}else{
		printf("%d\n",min);
	}
	
	return 0;
}
            
            
            
        