Submission #3306029


Source Code Expand

#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    int n; cin >> n;
    map<int, int> map1, map2;
    
    for (int i = 1; i <= n/2; i++) {
        int vOdd, vEven;
        cin >> vOdd >> vEven;
        if (map1.count(vOdd) == 0) {
            map1[vOdd] = 1;
        } else {
            map1[vOdd]++;
        }
        if (map2.count(vEven) == 0) {
            map2[vEven] = 1;
        } else {
            map2[vEven]++;
        }
    }
    
    int oddKey1, oddValue1 = 0, evenKey1, evenValue1 = 0;
    int oddKey2, oddValue2 = 0, evenKey2, evenValue2 = 0;
    for (auto it = map1.begin(); it != map1.end(); ++it) {
        if (oddValue1 <= it->second) {
            oddValue1 = it->second;
            oddKey1 = it->first;
        }
    }
    for (auto it = map1.begin(); it != map1.end(); ++it) {
        if (oddValue2 <= it->second && oddValue1 != it->second) {
            oddValue2 = it->second;
            oddKey2 = it->first;
        }
    }
    for (auto it = map2.begin(); it != map2.end(); ++it) {
        if (evenValue1 <= it->second) {
            evenValue1 = it->second;
            evenKey1 = it->first;
        }
    }
    for (auto it = map2.begin(); it != map2.end(); ++it) {
        if (evenValue2 <= it->second && evenValue1 != it->second) {
            evenValue2 = it->second;
            evenKey2 = it->first;
        }
    }
    
    if (oddKey1 != evenKey1) {
        cout << n - oddValue1 - evenValue1 << endl;
    } else if (oddValue1 + evenValue2 >= oddValue2 + evenValue1) {
        cout << n - (oddValue1 + evenValue2) << endl;
    } else {
        cout << n - (oddValue2 + evenValue1) << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User Shiro_K
Language C++14 (Clang 3.8.0)
Score 0
Code Size 1785 Byte
Status WA
Exec Time 122 ms
Memory 4992 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 15
WA × 5
Set Name Test Cases
Sample sample1_3132.txt, sample2_iw.txt, sample3_1111.txt
All 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 AC 105 ms 3192 KiB
ababa_1.txt AC 97 ms 2560 KiB
eq_0.txt WA 79 ms 256 KiB
eq_1.txt WA 80 ms 256 KiB
rnd_17.txt AC 79 ms 256 KiB
sample1_3132.txt AC 1 ms 256 KiB
sample2_iw.txt AC 1 ms 256 KiB
sample3_1111.txt AC 1 ms 256 KiB
top2_0.txt WA 86 ms 512 KiB
top2_1.txt WA 86 ms 640 KiB
top2_2.txt AC 86 ms 640 KiB
top2_3.txt AC 85 ms 512 KiB
top2modoki_0.txt AC 86 ms 640 KiB
top2modoki_1.txt AC 84 ms 640 KiB
top2modoki_2.txt AC 86 ms 512 KiB
top2modoki_3.txt AC 85 ms 512 KiB
vary_1.txt AC 122 ms 4992 KiB
vary_2.txt WA 117 ms 4864 KiB
vary_3.txt AC 108 ms 3328 KiB
zoro_0.txt AC 1 ms 256 KiB