Submission #3291644


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    map<int,int> a,b;
    REP(i,n/2){
        int x,y;
        cin>>x>>y;
        a[x]++;
        b[y]++;
    }
    vector<P> p,q;
    for(auto itr:a){
        p.pb({itr.se,itr.fi});
    }
    for(auto itr:b){
        q.pb({itr.se,itr.fi});
    }
    sort(q.rbegin(),q.rend());
    int ans=n;
    REP(i,p.size()){
        REP(j,q.size()){
            if(p[i].se!=q[j].se){
                chmin(ans,n-p[i].fi-q[j].fi);
                break;
            }else{
                chmin(ans,n-max(p[i].fi,q[j].fi));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User SugarDragon5
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1388 Byte
Status
Exec Time 66 ms
Memory 6136 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 45 ms 3196 KB
ababa_1.txt 46 ms 3196 KB
eq_0.txt 30 ms 256 KB
eq_1.txt 30 ms 256 KB
rnd_17.txt 30 ms 256 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 35 ms 640 KB
top2_1.txt 34 ms 640 KB
top2_2.txt 34 ms 640 KB
top2_3.txt 36 ms 640 KB
top2modoki_0.txt 39 ms 640 KB
top2modoki_1.txt 34 ms 640 KB
top2modoki_2.txt 35 ms 640 KB
top2modoki_3.txt 35 ms 640 KB
vary_1.txt 66 ms 6136 KB
vary_2.txt 60 ms 6012 KB
vary_3.txt 52 ms 4344 KB
zoro_0.txt 1 ms 256 KB