CODE FESTIVAL 2016 Final

Submission #991979

Source codeソースコード

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int A[100050];
vector<int> X[100050];

int calc(int a, int b) {
  if (X[a].size() > X[b].size()) {
    swap(a, b);
  }
  int res = X[a].size();
  int rem = X[b].size() - X[a].size();
  int pr = 0;
  for (int i = 0; i + 1 < X[b].size(); ++i) {
    if (X[b][i] == X[b][i + 1]) {
      ++pr;
      ++i;
    }
  }
  return res + min(rem, pr);
}

int main() {
  int N = in();
  int M = in();

  for (int i = 0; i < N; ++i) {
    A[i] = in();
    X[A[i] % M].push_back(A[i]);
  }

  int res = 0;
  for (int i = 0; i <= M - i; ++i) {
    int j = (M - i) % M;
    if (i == j) {
      res += X[i].size() / 2;
    } else {
      sort(X[i].begin(), X[i].end());
      sort(X[j].begin(), X[j].end());
      res += calc(i, j);
    }
  }

  printf("%d\n", res);

  return 0;
}

Submission

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

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

./Main.cpp: In function ‘int in()’:
./Main.cpp:34:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int in() { int x; scanf("%d", &x); return x; }
^
./Main.cpp: In function ‘double fin()’:
./Main.cpp:35:42: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
double fin() { double x; scanf("%lf", &x); return x; }
^
./Main.cpp: In function ‘Int lin()’:
./Main.cpp:36:37: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
Int lin() { Int x; scanf("%lld", &x); return x; }
^

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 0 / 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 2560 KB
01-02.txt AC 16 ms 3452 KB
01-03.txt AC 16 ms 3580 KB
01-04.txt WA
01-05.txt WA
01-06.txt WA
01-07.txt WA
01-08.txt WA
01-09.txt WA
01-10.txt WA
01-11.txt WA
01-12.txt AC 17 ms 3452 KB
01-13.txt AC 17 ms 3452 KB
01-14.txt AC 16 ms 3472 KB
01-15.txt AC 20 ms 3584 KB
01-16.txt AC 20 ms 3712 KB
01-17.txt AC 19 ms 3456 KB
01-18.txt AC 21 ms 3840 KB
01-19.txt AC 23 ms 3712 KB
01-20.txt AC 25 ms 6144 KB
01-21.txt AC 16 ms 3520 KB
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt AC 15 ms 4352 KB
01-28.txt WA
01-29.txt AC 5 ms 2560 KB
01-30.txt AC 5 ms 2560 KB
sample-01.txt AC 5 ms 2560 KB
sample-02.txt AC 5 ms 2560 KB