結果
| 問題 | No.29 パワーアップ | 
| コンテスト | |
| ユーザー |  toto | 
| 提出日時 | 2025-03-27 10:27:54 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 686 bytes | 
| コンパイル時間 | 174 ms | 
| コンパイル使用メモリ | 29,832 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-10-24 21:21:36 | 
| 合計ジャッジ時間 | 961 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 22 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d",&val);
      |         ~~~~~^~~~~~~~~~~
main.cpp:13:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |                         scanf("%d",&drop[i]);
      |                         ~~~~~^~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
int main(){
	int item[10] = {0,0,0,0,0,0,0,0,0,0};
	
	// 敵討伐回数
	int val = 0;
	scanf("%d",&val);
	// ドロップアイテムを配列に格納
	for(int i = 0;i < val;i ++){
		int drop[3];
		for(int i = 0;i < 3;i ++){
			scanf("%d",&drop[i]);
			item[drop[i] - 1]++;
		}
	}
	
	// パワーアップ回数をカウント
	int count = 0;
	// 2つ揃えれなかったアイテムの個数
	int remain = 0;
	// パワーアップ回数とアイテムを2つ揃えれなかった個数を判別
	for(int i = 0;i < 10;i ++){
		count += item[i] / 2;
		remain += item[i] % 2;
	}
	// 任意の4つでパワーアップ
	count += remain / 4;
	
	printf("%d",count);
}
            
            
            
        