結果

問題 No.1972 Modulo Set
ユーザー SSRSSSRS
提出日時 2022-06-10 21:22:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 1,891 ms
コンパイル使用メモリ 175,908 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-15 08:42:29
合計ジャッジ時間 5,926 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 16 ms
5,376 KB
testcase_04 AC 23 ms
5,376 KB
testcase_05 AC 26 ms
5,376 KB
testcase_06 AC 42 ms
5,376 KB
testcase_07 AC 65 ms
5,376 KB
testcase_08 AC 28 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 23 ms
5,376 KB
testcase_11 AC 63 ms
5,376 KB
testcase_12 AC 11 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 79 ms
6,784 KB
testcase_16 AC 92 ms
8,576 KB
testcase_17 AC 28 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 73 ms
8,576 KB
testcase_20 AC 98 ms
9,472 KB
testcase_21 AC 34 ms
5,412 KB
testcase_22 AC 70 ms
8,448 KB
testcase_23 AC 164 ms
17,024 KB
testcase_24 AC 52 ms
9,060 KB
testcase_25 AC 89 ms
11,776 KB
testcase_26 AC 114 ms
7,680 KB
testcase_27 AC 191 ms
17,792 KB
testcase_28 AC 57 ms
9,300 KB
testcase_29 AC 97 ms
12,108 KB
testcase_30 AC 142 ms
15,232 KB
testcase_31 AC 6 ms
5,376 KB
testcase_32 AC 126 ms
14,208 KB
testcase_33 AC 204 ms
19,712 KB
testcase_34 AC 212 ms
19,584 KB
testcase_35 AC 225 ms
19,584 KB
testcase_36 AC 222 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  long long M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  set<long long> st;
  map<long long, int> mp;
  for (int i = 0; i < N; i++){
    long long r = A[i] % M;
    mp[r]++;
    r = min(r, M - r);
    st.insert(r);
  }
  int ans = 0;
  for (long long x : st){
    if (x == 0 || x * 2 == M){
      ans++;
    } else {
      ans += max(mp[x], mp[M - x]);
    }
  }
  cout << ans << endl;
}
0