Submission #3292559


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;


#define pb push_back
#define fo(i, n) for(int i = 1; i <= n; ++i)

const int mod = 1e9 + 7;
const int N = 700012;
const int inf = 2e9;
typedef long long ll;
int n;
map<int, int> cnt;
int a[N];
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    fo(i, n) cin >> a[i], cnt[a[i]]++;
    int k = n >> 1;
    vector<int> res;
    for(auto x : cnt) {
        res.pb(x.second);
    }
    while(res.size() < 2) res.pb(0);
    sort(res.begin(), res.end());
    reverse(res.begin(), res.end());
    cout << n - (res[0] + res[1]) + max(res[0] - k, 0);
    return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User Speedster
Language C++14 (GCC 5.4.1)
Score 0
Code Size 654 Byte
Status
Exec Time 45 ms
Memory 6016 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1_3132.txt, sample2_iw.txt, sample3_1111.txt
All 0 / 300 ababa_0.txt, ababa_1.txt, eq_0.txt, eq_1.txt, rnd_17.txt, sample1_3132.txt, sample2_iw.txt, sample3_1111.txt, top2_0.txt, top2_1.txt, top2_2.txt, top2_3.txt, top2modoki_0.txt, top2modoki_1.txt, top2modoki_2.txt, top2modoki_3.txt, vary_1.txt, vary_2.txt, vary_3.txt, zoro_0.txt
Case Name Status Exec Time Memory
ababa_0.txt 25 ms 3328 KB
ababa_1.txt 25 ms 3328 KB
eq_0.txt 10 ms 640 KB
eq_1.txt 10 ms 640 KB
rnd_17.txt 9 ms 640 KB
sample1_3132.txt 1 ms 256 KB
sample2_iw.txt 1 ms 256 KB
sample3_1111.txt 1 ms 256 KB
top2_0.txt 15 ms 1024 KB
top2_1.txt 15 ms 1024 KB
top2_2.txt 15 ms 1024 KB
top2_3.txt 15 ms 1024 KB
top2modoki_0.txt 15 ms 1024 KB
top2modoki_1.txt 15 ms 1024 KB
top2modoki_2.txt 15 ms 1024 KB
top2modoki_3.txt 15 ms 1024 KB
vary_1.txt 45 ms 6016 KB
vary_2.txt 28 ms 3328 KB
vary_3.txt 23 ms 2560 KB
zoro_0.txt 1 ms 256 KB