Submission #3814154
Source Code Expand
//----------------------------templates
#pragma GCC optimize ("Ofast")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
#define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define REPS(i,n) for (int i=1;i<=(int)(n);i++)
#define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
#define REPNS(i,n) for (int i=(int)(n);i>0;i--)
#define I(n) scanf("%lld", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
const int mod = 1000000007;
//--------------------------------------
int n,v;
map<int,int> v1, v2;
map<int,int> v1s, v2s;
signed main(){
I(n);
n /= 2;
REP(i,n){
I(v); v1[v]++;
I(v); v2[v]++;
}
int ret = 0;
pi v1f = {0,0};
pi v1s = {0,0};
for(auto pv : v1){
if (pv.second > v1f.second){
v1s = v1f;
v1f = pv;
} else if (pv.second > v1s.second){
v1s = pv;
}
}
pi v2f = {0,0};
pi v2s = {0,0};
for(auto pv : v2){
if (pv.second > v2f.second){
v2s = v2f;
v2f = pv;
} else if (pv.second > v2s.second){
v2s = pv;
}
}
if (v1f.first != v2f.first){
ret = 2 * n - v1f.second - v2f.second;
} else {
ret = 2*n - max(v1f.second + v2s.second , v1s.second + v2f.second);
}
cout << ret << endl;
}
Submission Info
Submission Time |
|
Task |
C - /\/\/\/ |
User |
omi |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
2183 Byte |
Status |
AC |
Exec Time |
50 ms |
Memory |
6528 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:49:9: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
I(n);
^
./Main.cpp:52:13: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
I(v); v1[v]++;
^
./Main.cpp:53:13: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
I(v); v2[v]++;
^
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 |
28 ms |
3328 KB |
ababa_1.txt |
AC |
28 ms |
3328 KB |
eq_0.txt |
AC |
11 ms |
256 KB |
eq_1.txt |
AC |
11 ms |
256 KB |
rnd_17.txt |
AC |
11 ms |
256 KB |
sample1_3132.txt |
AC |
1 ms |
256 KB |
sample2_iw.txt |
AC |
1 ms |
256 KB |
sample3_1111.txt |
AC |
1 ms |
256 KB |
top2_0.txt |
AC |
16 ms |
640 KB |
top2_1.txt |
AC |
16 ms |
640 KB |
top2_2.txt |
AC |
16 ms |
640 KB |
top2_3.txt |
AC |
17 ms |
640 KB |
top2modoki_0.txt |
AC |
16 ms |
640 KB |
top2modoki_1.txt |
AC |
16 ms |
640 KB |
top2modoki_2.txt |
AC |
17 ms |
640 KB |
top2modoki_3.txt |
AC |
16 ms |
640 KB |
vary_1.txt |
AC |
50 ms |
6528 KB |
vary_2.txt |
AC |
45 ms |
6400 KB |
vary_3.txt |
AC |
35 ms |
4352 KB |
zoro_0.txt |
AC |
1 ms |
256 KB |