結果

問題 No.1972 Modulo Set
ユーザー rurunrurun
提出日時 2022-11-18 15:42:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 178,488 KB
実行使用メモリ 10,184 KB
最終ジャッジ日時 2023-10-20 01:56:34
合計ジャッジ時間 4,876 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 14 ms
4,348 KB
testcase_04 AC 20 ms
4,348 KB
testcase_05 AC 23 ms
4,348 KB
testcase_06 AC 36 ms
4,348 KB
testcase_07 AC 56 ms
4,376 KB
testcase_08 AC 26 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 20 ms
4,348 KB
testcase_11 AC 54 ms
4,376 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 61 ms
5,960 KB
testcase_16 AC 67 ms
6,488 KB
testcase_17 AC 23 ms
4,548 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 53 ms
6,224 KB
testcase_20 AC 69 ms
6,752 KB
testcase_21 AC 28 ms
4,672 KB
testcase_22 AC 44 ms
5,960 KB
testcase_23 AC 88 ms
9,128 KB
testcase_24 AC 33 ms
5,696 KB
testcase_25 AC 51 ms
6,752 KB
testcase_26 AC 81 ms
6,488 KB
testcase_27 AC 96 ms
9,392 KB
testcase_28 AC 32 ms
5,720 KB
testcase_29 AC 49 ms
6,752 KB
testcase_30 AC 69 ms
8,072 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 62 ms
7,544 KB
testcase_33 AC 110 ms
10,184 KB
testcase_34 AC 109 ms
10,184 KB
testcase_35 AC 109 ms
10,184 KB
testcase_36 AC 115 ms
9,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main() {
  lint n, m;
  cin >> n >> m;
  vector<lint> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  map<lint, lint> ma;
  map<lint, lint> ma2;
  for (int i = 0; i < n; i++) {
    if (vec[i]%m == 0) ma2[vec[i]]++;
    else ma[vec[i]%m]++;
  }
  lint ans = 0;
  for (auto pa : ma) {
    lint x = pa.first;
    lint y = pa.second;
    if (m-x == x) ans++;
    else if (ma.count(m-x)) {
      if (m-x > x) ans += max(y, ma.at(m-x));
    }
    else ans += y;
    /*
    if (m-x == x) ans++;
    else if (m-x < x) break;
    else {
      if (ma.count(m-x)) {
        ans += max(ma.at(m-x), y);
      }
    }
    //*/
  }
  lint high = 0;
  for (auto x : ma2) high = max(high, x.second);
  cout << ans+high << endl;
}
0