結果

問題 No.1972 Modulo Set
ユーザー mmn15277198mmn15277198
提出日時 2022-08-04 23:53:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 1,885 ms
コンパイル使用メモリ 175,312 KB
実行使用メモリ 26,612 KB
最終ジャッジ日時 2023-10-12 22:04:38
合計ジャッジ時間 7,849 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 17 ms
4,352 KB
testcase_04 AC 23 ms
4,352 KB
testcase_05 AC 26 ms
4,352 KB
testcase_06 AC 43 ms
4,352 KB
testcase_07 AC 66 ms
4,852 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 65 ms
4,916 KB
testcase_12 AC 12 ms
4,352 KB
testcase_13 AC 9 ms
4,352 KB
testcase_14 AC 10 ms
4,384 KB
testcase_15 AC 92 ms
8,148 KB
testcase_16 AC 115 ms
10,528 KB
testcase_17 AC 33 ms
5,580 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 101 ms
10,676 KB
testcase_20 AC 140 ms
11,840 KB
testcase_21 AC 40 ms
5,780 KB
testcase_22 AC 91 ms
10,184 KB
testcase_23 AC 300 ms
22,672 KB
testcase_24 AC 92 ms
11,300 KB
testcase_25 AC 151 ms
15,252 KB
testcase_26 AC 128 ms
9,072 KB
testcase_27 AC 322 ms
23,820 KB
testcase_28 AC 94 ms
11,712 KB
testcase_29 AC 162 ms
15,756 KB
testcase_30 AC 243 ms
20,508 KB
testcase_31 AC 8 ms
4,352 KB
testcase_32 AC 208 ms
18,860 KB
testcase_33 AC 383 ms
26,520 KB
testcase_34 AC 370 ms
26,612 KB
testcase_35 AC 366 ms
26,576 KB
testcase_36 AC 359 ms
26,520 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] * 2 == m) 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