Submission #3300454
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
using VI = vector<int>;
using VII = vector<pair<int, int> >;
using MII = map<int, int>;
const int X = 300000;
VII freqs(const MII& m) {
VII v;
for (auto const& kv: m) {
v.push_back(make_pair(kv.second, kv.first));
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
return v;
}
int main() {
int N;
cin >> N;
MII ma, mb;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
if (i % 2 == 0) {
ma[a]++;
} else {
mb[a]++;
}
}
ma[X] = 0;
mb[X] = 0;
VII fa = freqs(ma);
VII fb = freqs(mb);
int res;
if (fa[0].second == fb[0].second) {
res = min(N - fa[1].first - fb[0].first, N - fa[0].first - fb[1].first);
} else {
res = N - fa[0].first - fb[0].first;
}
cout << res << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - /\/\/\/ |
| User | doseisan |
| Language | C++14 (GCC 5.4.1) |
| Score | 300 |
| Code Size | 944 Byte |
| Status | AC |
| Exec Time | 83 ms |
| Memory | 6136 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| 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 | 52 ms | 3196 KiB |
| ababa_1.txt | AC | 52 ms | 3196 KiB |
| eq_0.txt | AC | 31 ms | 256 KiB |
| eq_1.txt | AC | 31 ms | 256 KiB |
| rnd_17.txt | AC | 33 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 | AC | 36 ms | 640 KiB |
| top2_1.txt | AC | 35 ms | 640 KiB |
| top2_2.txt | AC | 35 ms | 640 KiB |
| top2_3.txt | AC | 36 ms | 640 KiB |
| top2modoki_0.txt | AC | 36 ms | 640 KiB |
| top2modoki_1.txt | AC | 35 ms | 640 KiB |
| top2modoki_2.txt | AC | 39 ms | 640 KiB |
| top2modoki_3.txt | AC | 36 ms | 640 KiB |
| vary_1.txt | AC | 83 ms | 6136 KiB |
| vary_2.txt | AC | 74 ms | 6012 KiB |
| vary_3.txt | AC | 56 ms | 4344 KiB |
| zoro_0.txt | AC | 1 ms | 256 KiB |