結果

問題 No.29 パワーアップ
ユーザー @abcde
提出日時 2019-02-04 23:41:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 607 bytes
コンパイル時間 2,461 ms
コンパイル使用メモリ 164,700 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 04:52:34
合計ジャッジ時間 3,035 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    
    // 1. 入力情報取得.
    int N;
    cin >> N;
    map<int, int> m;
    for(int i = 0; i < N; i++){
        int a, b, c;
        cin >> a >> b >> c;
        m[a]++, m[b]++, m[c]++;
    }

    // 2. 同じアイテムを2個ずつ消費.
    int ans = 0;
    int remain = 0;
    for(auto &p : m){
        int c = p.second / 2;
        remain += (p.second - c * 2);
        ans += c;
    }
    
    // 3. 異なるアイテムを4個ずつ消費.
    ans += (remain / 4);

    // 4. 出力.
    cout << ans << endl;
    return 0;
    
}
0