結果
| 問題 | 
                            No.29 パワーアップ
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-03-17 23:25:10 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 1 ms / 5,000 ms | 
| コード長 | 650 bytes | 
| コンパイル時間 | 148 ms | 
| コンパイル使用メモリ | 29,452 KB | 
| 実行使用メモリ | 7,716 KB | 
| 最終ジャッジ日時 | 2025-10-24 21:05:41 | 
| 合計ジャッジ時間 | 922 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 22 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf("%d %d %d",&a,&b,&c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <stdio.h>
int main(){
    //input
    int N;
    scanf("%d",&N);
    int itemCount[10] = {0};
    for (int i = 0;i < N;i++){
        int a,b,c;
        scanf("%d %d %d",&a,&b,&c);
        itemCount[a-1]++;
        itemCount[b-1]++;
        itemCount[c-1]++;
    }
    //calculate power up count
    int puCount = 0;
    int oddCount = 0;
    for (int i = 0;i < 10;i++){
        if (itemCount[i]%2 == 0){
            puCount += itemCount[i]/2;
        }else{
            puCount += (itemCount[i]-1)/2;
            oddCount++;
        }
    }
    puCount += (oddCount-oddCount%4)/4;
    //output
    printf("%d\n",puCount);
    return 0;
}