結果

問題 No.29 パワーアップ
ユーザー rsk0315
提出日時 2020-03-15 21:56:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 56,016 KB
最終ジャッジ日時 2025-01-09 07:09:52
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |   scanf("%zu", &n);
      |   ~~~~~^~~~~~~~~~~
main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |     scanf("%zu", &j);
      |     ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <algorithm>
#include <numeric>
#include <vector>

int main() {
  size_t n;
  scanf("%zu", &n);
  n *= 3;

  std::vector<int> a(11, 0);
  for (size_t i = 0; i < n; ++i) {
    size_t j;
    scanf("%zu", &j);
    ++a[j];
  }

  int res = 0;
  for (auto& ai: a) {
    res += ai / 2;
    ai %= 2;
  }

  res += std::accumulate(a.begin(), a.end(), 0) / 4;
  printf("%d\n", res);
}
0