Submission #3300303


Source Code Expand

Copy
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x) {
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
const int N=100010;
int n;
int a[N];
int cnt[2][N];
int Ma[2],id[2];
int Se[2],iid[2];
signed main() {
  read(n);
  for(int i=1;i<=n;i++) {
    read(a[i]);
    ++cnt[i&1][a[i]];
  }
  for(int i=1;i<=100000;i++) {
    for(int j=0;j<2;j++)
      if(Ma[j]<cnt[j][i]) {
	Ma[j]=cnt[j][i];
	id[j]=i;
      }
  }
  if(id[0]!=id[1]) {
    printf("%d\n",n-Ma[0]-Ma[1]);
    return 0;
  }
  for(int i=1;i<=100000;i++) {
    for(int j=0;j<2;j++)
      if(Se[j]<cnt[j][i] && id[j]!=i && id[j^1]!=i) {
	Se[j]=cnt[j][i];
	iid[j]=i;
      }
  }
  printf("%d\n",min(n-Ma[0]-Se[1],n-Ma[1]-Se[0]));
  return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User functionendless
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1517 Byte
Status
Exec Time 7 ms
Memory 1408 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 6 ms 1024 KB
ababa_1.txt 6 ms 1024 KB
eq_0.txt 6 ms 768 KB
eq_1.txt 6 ms 768 KB
rnd_17.txt 6 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 6 ms 1408 KB
top2_1.txt 6 ms 1408 KB
top2_2.txt 7 ms 1408 KB
top2_3.txt 7 ms 1408 KB
top2modoki_0.txt 7 ms 1408 KB
top2modoki_1.txt 7 ms 1408 KB
top2modoki_2.txt 6 ms 1408 KB
top2modoki_3.txt 6 ms 1408 KB
vary_1.txt 6 ms 1408 KB
vary_2.txt 6 ms 1408 KB
vary_3.txt 6 ms 1408 KB
zoro_0.txt 1 ms 256 KB