CODE FESTIVAL 2016 Final

Submission #992729

Source codeソースコード

#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

Task問題 D - Pair Cards
User nameユーザ名 021_roxion1377
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 700
Source lengthソースコード長 1211 Byte
File nameファイル名
Exec time実行時間 27 ms
Memory usageメモリ使用量 6784 KB

Compiler messageコンパイルメッセージ

./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);
^

Test case

Set

Set name Score得点 / Max score Cases
sample - 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt AC 5 ms 3328 KB
01-02.txt AC 23 ms 4216 KB
01-03.txt AC 23 ms 4220 KB
01-04.txt AC 23 ms 4216 KB
01-05.txt AC 22 ms 4224 KB
01-06.txt AC 22 ms 4352 KB
01-07.txt AC 21 ms 4096 KB
01-08.txt AC 21 ms 4352 KB
01-09.txt AC 21 ms 4224 KB
01-10.txt AC 25 ms 4864 KB
01-11.txt AC 27 ms 5632 KB
01-12.txt AC 18 ms 4216 KB
01-13.txt AC 18 ms 4216 KB
01-14.txt AC 22 ms 4240 KB
01-15.txt AC 22 ms 4352 KB
01-16.txt AC 21 ms 4352 KB
01-17.txt AC 20 ms 4224 KB
01-18.txt AC 22 ms 4480 KB
01-19.txt AC 23 ms 4480 KB
01-20.txt AC 27 ms 6784 KB
01-21.txt AC 22 ms 4160 KB
01-22.txt AC 21 ms 4224 KB
01-23.txt AC 20 ms 4224 KB
01-24.txt AC 20 ms 4224 KB
01-25.txt AC 21 ms 4352 KB
01-26.txt AC 22 ms 4352 KB
01-27.txt AC 16 ms 4992 KB
01-28.txt AC 7 ms 3328 KB
01-29.txt AC 6 ms 3328 KB
01-30.txt AC 6 ms 3328 KB
sample-01.txt AC 5 ms 3328 KB
sample-02.txt AC 5 ms 3328 KB