結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー mamekinmamekin
提出日時 2015-01-20 22:35:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 903 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 102,952 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-05 02:10:55
合計ジャッジ時間 1,713 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
4,384 KB
testcase_01 AC 49 ms
4,376 KB
testcase_02 AC 25 ms
4,376 KB
testcase_03 AC 49 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int t;
    cin >> t;

    while(--t >= 0){
        int n;
        cin >> n;

        map<int, int> cnt;
        for(int i=0; i<n; ++i){
            int len;
            cin >> len;
            ++ cnt[len];
        }

        vector<int> v;
        for(auto p : cnt)
            v.push_back(p.second);
        sort(v.rbegin(), v.rend());

        int ret = 0;
        if(v.size() >= 3)
            ret = min({n / 3, (n - v[0]) / 2, n - v[0] - v[1]});
        cout << ret << endl;
    }

    return 0;
}
0