Submission #992729


Source Code Expand

Copy
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

int n, m;
int x[111111];
vector<int> y[111111];
int z[111111];

int test() {
  /*
  vector<int> v;
  
  for (int i = 0; i < n; i++) {
    v.push_back(x[i]);
  }

  int res = 0;
  do {
  for (int i = 0; i < n-1; i++) {
  }
  } while(next_permutation(v.begin(), v.end()));
  */
}

int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", x+i);
    y[x[i]%m].push_back(x[i]);
  }

  int res = 0;
  memset(z, -1, sizeof(z));
  for (int i = 0; i < m; i++) {
    if (z[i] >= 0) continue;
    int p = i;
    int q = (m-i)%m;
    if (p == q) {
      z[p] = y[p].size();
      res += z[p]/2;
    } else {
      z[p] = z[q] = min(y[p].size(), y[q].size());
      res += z[p];
    }
  }

  for (int i = 0; i < m; i++) {
    sort(y[i].begin(), y[i].end());
    // printf("%d/%zd\n", z[i], y[i].size());
    for (int j = 0; j < int(y[i].size())-1; j++) {
      if (y[i][j] == y[i][j+1] && z[i]+2 <= int(y[i].size())) {
        z[i] += 2;
        res += 1;
        j++;
      }
    }
  }
  
  printf("%d\n", res);
  return 0;
}

Submission Info

Submission Time
Task D - Pair Cards
User roxion1377
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1211 Byte
Status
Exec Time 27 ms
Memory 6784 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:30:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &m);
                        ^
./Main.cpp:32:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", x+i);
                     ^

Judge Result

Set Name Score / Max Score Test Cases
sample 0 / 0 sample-01.txt, sample-02.txt
all 700 / 700 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt
Case Name Status Exec Time Memory
01-01.txt 5 ms 3328 KB
01-02.txt 23 ms 4216 KB
01-03.txt 23 ms 4220 KB
01-04.txt 23 ms 4216 KB
01-05.txt 22 ms 4224 KB
01-06.txt 22 ms 4352 KB
01-07.txt 21 ms 4096 KB
01-08.txt 21 ms 4352 KB
01-09.txt 21 ms 4224 KB
01-10.txt 25 ms 4864 KB
01-11.txt 27 ms 5632 KB
01-12.txt 18 ms 4216 KB
01-13.txt 18 ms 4216 KB
01-14.txt 22 ms 4240 KB
01-15.txt 22 ms 4352 KB
01-16.txt 21 ms 4352 KB
01-17.txt 20 ms 4224 KB
01-18.txt 22 ms 4480 KB
01-19.txt 23 ms 4480 KB
01-20.txt 27 ms 6784 KB
01-21.txt 22 ms 4160 KB
01-22.txt 21 ms 4224 KB
01-23.txt 20 ms 4224 KB
01-24.txt 20 ms 4224 KB
01-25.txt 21 ms 4352 KB
01-26.txt 22 ms 4352 KB
01-27.txt 16 ms 4992 KB
01-28.txt 7 ms 3328 KB
01-29.txt 6 ms 3328 KB
01-30.txt 6 ms 3328 KB
sample-01.txt 5 ms 3328 KB
sample-02.txt 5 ms 3328 KB