Submission #3294089


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> cnt1, cnt2;
int a[N];
inline bool cmp(pair<int,int> a, pair<int,int> b) {
    if(a.second!=b.second) return a.second>b.second;
    return a.first<b.first;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    fo(i, n) cin >> a[i];
    for(int i = 1; i <= n; i += 2)
        cnt1[a[i]]++;
    for(int i = 2; i <= n; i += 2)
        cnt2[a[i]]++;
    cnt1[0] = 0;
    cnt2[0] = 0;
    int c = 0;
    int ans = 0;
    vector<pair<int,int>> r1;
    vector<pair<int,int>> r2;
    for(auto x: cnt1)
        r1.pb(x);
    for(auto y : cnt2)
        r2.pb(y);
    sort(r1.begin(),r1.end(), cmp);
    sort(r2.begin(),r2.end(), cmp);
    for(auto x : r1) {
        ++c;
        if(c > 4) break;
        for(auto y : r2) {
            if(x.first != y.first) ans = max(ans, x.second + y.second);
        }
    }
    cout << n - ans;
    return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User Speedster
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1131 Byte
Status
Exec Time 44 ms
Memory 6524 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1_3132.txt, sample2_iw.txt, sample3_1111.txt
All 300 / 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 26 ms 3580 KB
ababa_1.txt 27 ms 3580 KB
eq_0.txt 9 ms 640 KB
eq_1.txt 9 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 14 ms 1152 KB
top2_1.txt 15 ms 1024 KB
top2_2.txt 14 ms 1152 KB
top2_3.txt 14 ms 1024 KB
top2modoki_0.txt 14 ms 1152 KB
top2modoki_1.txt 15 ms 1024 KB
top2modoki_2.txt 14 ms 1152 KB
top2modoki_3.txt 14 ms 1024 KB
vary_1.txt 44 ms 6524 KB
vary_2.txt 44 ms 6396 KB
vary_3.txt 36 ms 4728 KB
zoro_0.txt 1 ms 256 KB