Submission #3442720


Source Code Expand

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
using namespace std;



int main()
{
	int n;
	cin >> n;
	int v[10005];
	map<int, int> holdFirst, holdSecond;

	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}

	vector<int> a(10005), b(10005);
	fill(a.begin(), a.end(), 0);
	fill(b.begin(), b.end(), 0);

	for (int i = 1; i <= n; i++) {
		if (i % 2 == 1) {
			a[v[i]]++;
		}
		else {
			b[v[i]]++;
		}
	}

	int maxA = 0;
	int indexA = 0;
	int maxB = 0;
	int indexB = 0;

	for (int i = 1; i < 10005; i++) {
		if (a[i] > maxA) {
			maxA = a[i];
			indexA = i;
		}
		if (b[i] > maxB) {
			maxB = b[i];
			indexB = i;
		}
	}

	if (indexA != indexB) {
		cout << (n / 2 - maxA) + (n / 2 - maxB) << endl;
	}
	else {
		sort(a.begin(), a.end(), greater<int>());
		sort(b.begin(), b.end(), greater<int>());
		cout << min((n / 2 - a[0]) + (n / 2 - b[1]), (n / 2 - a[1]) + (n / 2 - a[0]));
	}
	
	return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User Mayimg
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1033 Byte
Status RE
Exec Time 101 ms
Memory 384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 3
RE × 17
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 RE 99 ms 256 KB
ababa_1.txt RE 99 ms 256 KB
eq_0.txt RE 99 ms 256 KB
eq_1.txt RE 100 ms 256 KB
rnd_17.txt RE 99 ms 256 KB
sample1_3132.txt AC 1 ms 384 KB
sample2_iw.txt AC 1 ms 384 KB
sample3_1111.txt AC 1 ms 384 KB
top2_0.txt RE 100 ms 256 KB
top2_1.txt RE 99 ms 256 KB
top2_2.txt RE 99 ms 256 KB
top2_3.txt RE 100 ms 256 KB
top2modoki_0.txt RE 101 ms 256 KB
top2modoki_1.txt RE 101 ms 256 KB
top2modoki_2.txt RE 99 ms 256 KB
top2modoki_3.txt RE 99 ms 256 KB
vary_1.txt RE 100 ms 256 KB
vary_2.txt RE 99 ms 256 KB
vary_3.txt RE 99 ms 256 KB
zoro_0.txt RE 96 ms 384 KB