結果

問題 No.1972 Modulo Set
ユーザー keisuke6
提出日時 2022-06-10 21:56:35
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 504 bytes
コンパイル時間 3,283 ms
コンパイル使用メモリ 253,220 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2024-09-21 06:15:21
合計ジャッジ時間 7,446 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 19 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int N,M;
  cin>>N>>M;
  vector<int> S(N);
  map<int,int> s;
  for(int i=0;i<N;i++){
      cin>>S[i];
      S[i] %= M;
      if(!s.count(S[i])) s[S[i]] = 0;
      s[S[i]]++;
  }
  int ans = 0;
  for(auto x:s){
      int a = x.first;
      int b = x.second;
      if(a == 0) ans++;
      else if(!s.count(M-a)) ans += b;
      else if(a == M-a) ans++;
      else if(a < M-a) ans += max(S[M-a],b);
  }
  cout<<ans<<endl;
}
0