結果

問題 No.29 パワーアップ
ユーザー mono1977
提出日時 2016-12-01 12:05:32
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 568 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 22,656 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 15:33:09
合計ジャッジ時間 1,411 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0