結果

問題 No.29 パワーアップ
コンテスト
ユーザー Syuutaro
提出日時 2018-03-17 23:25:10
言語 C++11
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 410µs
コード長 650 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 90 ms
コンパイル使用メモリ 39,424 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-15 22:03:04
合計ジャッジ時間 1,508 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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