結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-08-06 22:38:00 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 554 bytes | 
| コンパイル時間 | 2,522 ms | 
| コンパイル使用メモリ | 206,560 KB | 
| 最終ジャッジ日時 | 2025-01-07 10:54:49 | 
| ジャッジサーバーID (参考情報) | judge1 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 4 | 
ソースコード
#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;
}
            
            
            
        