結果

問題 No.1972 Modulo Set
ユーザー mmn15277198mmn15277198
提出日時 2022-08-04 23:51:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 1,563 ms
コンパイル使用メモリ 176,460 KB
実行使用メモリ 26,760 KB
最終ジャッジ日時 2023-10-12 22:02:14
合計ジャッジ時間 9,437 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 17 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 26 ms
4,352 KB
testcase_06 WA -
testcase_07 AC 65 ms
4,600 KB
testcase_08 AC 27 ms
4,352 KB
testcase_09 AC 5 ms
4,352 KB
testcase_10 AC 23 ms
4,352 KB
testcase_11 AC 64 ms
4,568 KB
testcase_12 WA -
testcase_13 AC 10 ms
4,520 KB
testcase_14 AC 10 ms
4,476 KB
testcase_15 AC 93 ms
8,108 KB
testcase_16 AC 111 ms
10,664 KB
testcase_17 AC 34 ms
5,536 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 97 ms
10,740 KB
testcase_20 AC 122 ms
11,796 KB
testcase_21 AC 40 ms
5,692 KB
testcase_22 AC 89 ms
10,204 KB
testcase_23 AC 273 ms
22,576 KB
testcase_24 AC 83 ms
11,296 KB
testcase_25 AC 135 ms
15,192 KB
testcase_26 AC 130 ms
9,108 KB
testcase_27 AC 308 ms
23,816 KB
testcase_28 AC 86 ms
11,540 KB
testcase_29 AC 148 ms
15,656 KB
testcase_30 AC 228 ms
20,396 KB
testcase_31 AC 8 ms
4,352 KB
testcase_32 AC 201 ms
18,920 KB
testcase_33 AC 350 ms
26,752 KB
testcase_34 AC 357 ms
26,760 KB
testcase_35 AC 359 ms
26,480 KB
testcase_36 AC 358 ms
26,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  map<long long, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= m;
    mp[a[i]]++;
  }
  long long ans = 0;
  bool ok1 = false;
  bool ok2 = false;
  map<long long, int> used;
  for (int i = 0; i < n; i++) {
    if (used[a[i]]) continue;
    if (a[i] == m / 2) ok1 = true;
    else if (a[i] == 0) ok2 = true;
    else ans += max(mp[a[i]], mp[m - a[i]]);
    used[a[i]]++;
    used[m - a[i]]++;
  }
  ans += ok1 + ok2;
  cout << ans << endl;
  return 0;
}
0