結果

問題 No.29 パワーアップ
コンテスト
ユーザー hiyori
提出日時 2016-09-23 12:19:36
言語 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
+ 250µs
コード長 653 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 321 ms
コンパイル使用メモリ 78,692 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-15 21:45:15
合計ジャッジ時間 1,561 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <vector>

#define REP(i, a) for(int i = 0; i < a; i++)

using namespace std;

/* 同じアイテム2つか任意のアイテム4つでパワーアップ */
int main ()
{
  int N;
  vector<int> items(10, 0);  // 0~9の10種類のアイテム
  cin >> N;
  REP(i, N) {
    REP(j, 3) {
      int get_item;
      cin >> get_item;
      items[get_item-1]++;
    }
  }

  int power_up = 0, cnt = 0;
  REP(i, items.size()) {
    if (items[i] > 1) {
      power_up += items[i] / 2;
      cnt += items[i] % 2;
    }
    else cnt += items[i];
  }
  power_up += cnt / 4;
  cout << power_up << endl;

  return 0;
}
0