Submission #6435087


Source Code Expand

Copy
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, v[100009], cnt[2][100009];
vector<pair<int, int> > vec[2];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		if (i % 2) cnt[1][v[i]]++;
		else cnt[0][v[i]]++;
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 1; j <= 100000; j++) {
			if (cnt[i][j]) vec[i].pb(make_pair(cnt[i][j], j));
		}
		sort(vec[i].begin(), vec[i].end());
		reverse(vec[i].begin(), vec[i].end());
	}
	int ans = vec[1][0].fi;
	if (vec[0][0].se == vec[1][0].se) {
		int tmp;
		int x, y;
		if (vec[1].size() > 1) x = vec[1][1].fi;
		else x = 0;
		if (vec[0].size() > 1) y = vec[0][1].fi;
		else y = 0;
		tmp = max(vec[0][0].fi + x, y + vec[1][0].fi);
		ans = max(ans, tmp);
	}
	else {
		ans = max(ans, vec[0][0].fi + vec[1][0].fi);
	}
	cout << n - ans << E;
	//system("pause");
	return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User mmmmmmmmmmmmmmmm
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1077 Byte
Status
Exec Time 15 ms
Memory 2552 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 11 ms 1660 KB
ababa_1.txt 12 ms 1660 KB
eq_0.txt 9 ms 768 KB
eq_1.txt 9 ms 768 KB
rnd_17.txt 9 ms 768 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 10 ms 1536 KB
top2_1.txt 10 ms 1536 KB
top2_2.txt 10 ms 1536 KB
top2_3.txt 10 ms 1536 KB
top2modoki_0.txt 10 ms 1536 KB
top2modoki_1.txt 10 ms 1536 KB
top2modoki_2.txt 10 ms 1536 KB
top2modoki_3.txt 10 ms 1536 KB
vary_1.txt 14 ms 2552 KB
vary_2.txt 14 ms 2552 KB
vary_3.txt 15 ms 2424 KB
zoro_0.txt 1 ms 256 KB