結果

問題 No.1972 Modulo Set
ユーザー monnu
提出日時 2022-06-10 21:40:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 3,273 ms
コンパイル使用メモリ 235,072 KB
実行使用メモリ 14,848 KB
最終ジャッジ日時 2024-10-05 01:28:54
合計ジャッジ時間 6,057 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define INF 1000000000000000000
#define MOD 998244353
#define MAX 500

int main(){
  int N;
  ll M;
  cin>>N>>M;
  map<ll,int> m;
  for(int i=0;i<N;i++){
    ll A;
    cin>>A;
    m[A%M]++;
  }

  ll ans=0;
  for(auto p:m){
    if((2*p.first)%M==0&&p.second>0){
      ans++;
    }else{
      if(p.second>=m[M-p.first]){
        ans+=p.second;
        m[M-p.first]=0;
      }
    }
  }
  cout<<ans<<'\n';
}
0