結果

問題 No.29 パワーアップ
コンテスト
ユーザー kekenx
提出日時 2020-03-06 09:51:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 168,476 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-24 21:13:18
合計ジャッジ時間 1,985 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  map<int, int> m;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    m[a]++; m[b]++; m[c]++;
    if (m[a] >= 2) {
      m[a] -= 2;
      ans++;
    }
    if (m[b] >= 2) {
      m[b] -= 2;
      ans++;
    }
    if (m[c] >= 2) {
      m[c] -= 2;
      ans++;
    }
  }

  int cnt = 0;
  for (auto &e: m) {
    cnt += e.second;
  }

  ans += cnt / 4;
  cout << ans << '\n';
  return 0;
}
0