結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー MisterMister
提出日時 2020-04-12 05:10:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 616 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 18:36:49
合計ジャッジ時間 1,622 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using lint = long long;

void solve() {
    std::map<int, int> cnt;

    int n;
    std::cin >> n;

    for (int i = 0; i < n; ++i) {
        int x;
        std::cin >> x;

        if (!cnt.count(x)) cnt[x] = 0;
        ++cnt[x];
    }

    int max = 0;
    for (auto p : cnt) {
        max = std::max(max, p.second);
    }

    std::cout << std::min(n / 3, (n - max) / 2) << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int q;
    std::cin >> q;
    while (q--) solve();

    return 0;
}
0