Submission #3305974

Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main(){
    int i, j, k;
    int N;
    cin >> N;
    vector<int> V(N);
    for(i=0; i<N; i++) cin >> V[i];

    map<int, int> cnt[2];
    for(i=0; i<N; i++) cnt[i%2][V[i]]++;

    vector<pair<int, int>> pairs[2];
    for(k=0; k<2; k++){
        cnt[k][0] = 0;
        for(auto&& p : cnt[k]) pairs[k].push_back({p.second, p.first});
        sort(pairs[k].rbegin(), pairs[k].rend());
    }

    int ans;
    if(pairs[0][0].second != pairs[1][0].second){
        ans = N - pairs[0][0].first - pairs[1][0].first;
    }else{
        ans = N - max(pairs[0][1].first + pairs[1][0].first, pairs[0][0].first + pairs[1][1].first);
    }

    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User betrue12
Language C++14 (GCC 5.4.1)
Score 300
Code Size 749 Byte
Status
Exec Time 64 ms
Memory 6520 KB

Test Cases

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 46 ms 3580 KB
ababa_1.txt 45 ms 3580 KB
eq_0.txt 29 ms 640 KB
eq_1.txt 29 ms 640 KB
rnd_17.txt 29 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 35 ms 1024 KB
top2_1.txt 35 ms 1024 KB
top2_2.txt 34 ms 1024 KB
top2_3.txt 35 ms 1024 KB
top2modoki_0.txt 35 ms 1024 KB
top2modoki_1.txt 35 ms 1024 KB
top2modoki_2.txt 35 ms 1024 KB
top2modoki_3.txt 35 ms 1024 KB
vary_1.txt 64 ms 6520 KB
vary_2.txt 59 ms 6396 KB
vary_3.txt 53 ms 4728 KB
zoro_0.txt 1 ms 256 KB