Submission #3453819


Source Code Expand

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#ifdef _MSC_VER
#define __builtin_popcount (int)__popcnt
#define __builtin_popcountll (int)__popcnt64
#define $ system("pause")
#else
#define $
#endif
#define MOD ll(998244353)
#define MAXN int(1e5 + 30)
#define lg 20
#define inf (ll)1e17

template <typename T, typename S>
inline T smin(T &a, const S &b) { return a > b ? a = b : a; }
template <typename T, typename S>
inline T smax(T &a, const S &b) { return a < b ? a = b : a; }
ll po(ll v, ll u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; }
inline void add(ll &l, const ll &r) { l = (1ll * l + r) % MOD; }
ll gcd(ll v, ll u) { return u ? gcd(u, v % u) : v; }

int n, arr[MAXN];
int h[2][MAXN];
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
	}
	for (int i = 1; i <= n; i++)
		h[i & 1][arr[i]]++;
	
	int aid = max_element(h[0], h[0] + MAXN) - h[0];
	int a = h[0][aid]; h[0][aid] = 0;
	int bid = max_element(h[0], h[0] + MAXN) - h[0];
	int b = h[0][bid]; h[0][bid] = 0;

	int cid = max_element(h[1], h[1] + MAXN) - h[1];
	int c = h[1][cid]; h[1][cid] = 0;
	int did = max_element(h[1], h[1] + MAXN) - h[1];
	int d = h[1][did]; h[1][did] = 0;

	if (aid != cid) cout << n - a - c << endl;
	else if (a + c == n) cout << n / 2 << endl;
	else
		cout << n - max(a + d, b + c) << endl;
	$;
	return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User MAMBA
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1658 Byte
Status AC
Exec Time 11 ms
Memory 1408 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
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 10 ms 1024 KB
ababa_1.txt AC 10 ms 1024 KB
eq_0.txt AC 10 ms 768 KB
eq_1.txt AC 10 ms 768 KB
rnd_17.txt AC 10 ms 768 KB
sample1_3132.txt AC 2 ms 256 KB
sample2_iw.txt AC 2 ms 256 KB
sample3_1111.txt AC 2 ms 256 KB
top2_0.txt AC 10 ms 1408 KB
top2_1.txt AC 10 ms 1408 KB
top2_2.txt AC 10 ms 1408 KB
top2_3.txt AC 10 ms 1408 KB
top2modoki_0.txt AC 10 ms 1408 KB
top2modoki_1.txt AC 11 ms 1408 KB
top2modoki_2.txt AC 10 ms 1408 KB
top2modoki_3.txt AC 10 ms 1408 KB
vary_1.txt AC 11 ms 1408 KB
vary_2.txt AC 11 ms 1408 KB
vary_3.txt AC 11 ms 1408 KB
zoro_0.txt AC 2 ms 256 KB