Submission #3295990


Source Code Expand

#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

typedef pair<int, int> P;
 
bool pairCompare(const P firstElof, const P secondElof)
{
    return firstElof.second > secondElof.second;
}

int main() {
  int n;
  scanf("%d", &n);
  P p1[100010], p2[100010];
  for (int i = 0; i < 100010; i++) {
    p1[i].first = 0;
    p1[i].second = 0;
    p2[i].first = 0;
    p2[i].second = 0;
  }
  for (int i = 0; i < n/2; i++) {
    int i1, i2;
    scanf("%d %d", &i1, &i2);
    p1[i1].first = i1;
    p2[i2].first = i2;
    p1[i1].second += 1;
    p2[i2].second += 1;
  }
  sort(p1, p1+100000, pairCompare);
  sort(p2, p2+100000, pairCompare);
  int ans = 0;
  if (p1[0].first == p2[0].first) {
    ans += n - max(p1[0].second+p2[1].second, p1[1].second+p2[0].second);
  } else {
    ans += n - (p1[0].second+p2[0].second);
  }
  //printf("%d %d %d", a[0], a[1], a[2]);
  //printf("%d %d %d %d\n", p1[0].first, p1[1].first, p1[0].second, p1[1].second);
  //printf("%d %d %d %d\n", p2[0].first, p2[1].first, p2[0].second, p2[1].second);
  printf("%d", ans);
  return 0;
}

Submission Info

Submission Time
Task C - /\/\/\/
User sauce
Language C++ (GCC 5.4.1)
Score 300
Code Size 1131 Byte
Status AC
Exec Time 18 ms
Memory 1664 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
./Main.cpp:26:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &i1, &i2);
                             ^

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 17 ms 1664 KiB
ababa_1.txt AC 17 ms 1664 KiB
eq_0.txt AC 16 ms 1664 KiB
eq_1.txt AC 16 ms 1664 KiB
rnd_17.txt AC 16 ms 1664 KiB
sample1_3132.txt AC 8 ms 1664 KiB
sample2_iw.txt AC 8 ms 1664 KiB
sample3_1111.txt AC 8 ms 1664 KiB
top2_0.txt AC 16 ms 1664 KiB
top2_1.txt AC 16 ms 1664 KiB
top2_2.txt AC 16 ms 1664 KiB
top2_3.txt AC 16 ms 1664 KiB
top2modoki_0.txt AC 16 ms 1664 KiB
top2modoki_1.txt AC 16 ms 1664 KiB
top2modoki_2.txt AC 16 ms 1664 KiB
top2modoki_3.txt AC 16 ms 1664 KiB
vary_1.txt AC 17 ms 1664 KiB
vary_2.txt AC 17 ms 1664 KiB
vary_3.txt AC 18 ms 1664 KiB
zoro_0.txt AC 8 ms 1664 KiB