結果

問題 No.1972 Modulo Set
ユーザー tnakao0123tnakao0123
提出日時 2022-06-12 23:07:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 804 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 57,896 KB
実行使用メモリ 9,856 KB
最終ジャッジ日時 2024-04-15 08:59:27
合計ジャッジ時間 3,049 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 8 ms
5,376 KB
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 12 ms
5,376 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 28 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 11 ms
5,376 KB
testcase_11 AC 28 ms
5,376 KB
testcase_12 AC 6 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 38 ms
5,760 KB
testcase_16 AC 43 ms
6,400 KB
testcase_17 AC 14 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 35 ms
6,016 KB
testcase_20 AC 46 ms
6,656 KB
testcase_21 AC 17 ms
5,376 KB
testcase_22 AC 31 ms
5,888 KB
testcase_23 AC 66 ms
8,832 KB
testcase_24 AC 22 ms
5,888 KB
testcase_25 AC 37 ms
6,784 KB
testcase_26 AC 51 ms
6,272 KB
testcase_27 AC 74 ms
8,960 KB
testcase_28 AC 22 ms
5,760 KB
testcase_29 AC 34 ms
6,912 KB
testcase_30 AC 55 ms
8,064 KB
testcase_31 AC 3 ms
5,376 KB
testcase_32 AC 45 ms
7,552 KB
testcase_33 AC 93 ms
9,728 KB
testcase_34 AC 87 ms
9,856 KB
testcase_35 AC 85 ms
9,728 KB
testcase_36 AC 86 ms
9,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1972.cc:  No.1972 Modulo Set - yukicoder
 */

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

using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;
typedef map<ll,int> mli;

/* global variables */

ll as[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  ll m;
  scanf("%d%lld", &n, &m);

  mli acs;
  for (int i = 0; i < n; i++) {
    ll ai;
    scanf("%lld", &ai);
    acs[ai % m]++;
  }

  int sum = 0;
  for (auto ac: acs) {
    ll a = ac.first, b = m - a;
    int c = ac.second;

    if (a == 0 || a * 2 == m) sum++;
    else {
      mli::iterator mit = acs.find(b);
      if (mit == acs.end()) sum += c;
      else if (a < b) sum += max(c, mit->second);
    }
  }

  printf("%d\n", sum);
  return 0;
}
0