結果

問題 No.1972 Modulo Set
ユーザー SSRS
提出日時 2022-06-10 21:22:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 180,876 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-09-21 05:54:17
合計ジャッジ時間 7,052 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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){
      ans += max(mp[x], mp[M - x]);
    } else {
      ans++;
    }
  }
  cout << ans << endl;
}
0