結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-06 22:38:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 2,649 ms
コンパイル使用メモリ 211,036 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 18:13:39
合計ジャッジ時間 2,889 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
    int n;cin>>n;
    map<int,int> mp;
    for (int i=0;i<n;i++) {
        int a;cin>>a;
        mp[a]++;
    }
    int m=mp.size();
    vector<int> v;
    for (auto p:mp) v.push_back(p.second);
    sort(v.rbegin(), v.rend());
    int ans=0;
    if (v.size() >= 3) {
        while (v[2]) {
            ans+=v[0];
            v[2]-=v[0];
            v[1]-=v[0];
            v[0]=0;
            sort(v.rbegin(),v.rend());
        }
    }
    cout<<ans<<endl;
    return 0;
}
0