結果

問題 No.1972 Modulo Set
ユーザー harurunharurun
提出日時 2022-06-10 23:02:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 1,513 bytes
コンパイル時間 3,735 ms
コンパイル使用メモリ 196,328 KB
実行使用メモリ 22,536 KB
最終ジャッジ日時 2023-07-27 22:27:55
合計ジャッジ時間 7,928 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 12 ms
4,380 KB
testcase_04 AC 17 ms
4,376 KB
testcase_05 AC 20 ms
4,380 KB
testcase_06 AC 30 ms
4,376 KB
testcase_07 AC 47 ms
4,800 KB
testcase_08 AC 23 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 18 ms
4,376 KB
testcase_11 AC 45 ms
4,500 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 7 ms
4,376 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 53 ms
6,716 KB
testcase_16 AC 63 ms
8,692 KB
testcase_17 AC 21 ms
4,932 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 57 ms
8,644 KB
testcase_20 AC 64 ms
9,360 KB
testcase_21 AC 24 ms
5,244 KB
testcase_22 AC 50 ms
8,396 KB
testcase_23 AC 147 ms
16,516 KB
testcase_24 AC 47 ms
9,004 KB
testcase_25 AC 93 ms
12,896 KB
testcase_26 AC 71 ms
8,364 KB
testcase_27 AC 169 ms
16,976 KB
testcase_28 AC 49 ms
9,064 KB
testcase_29 AC 95 ms
12,992 KB
testcase_30 AC 141 ms
15,256 KB
testcase_31 AC 6 ms
4,376 KB
testcase_32 AC 127 ms
14,676 KB
testcase_33 AC 229 ms
22,536 KB
testcase_34 AC 207 ms
22,400 KB
testcase_35 AC 212 ms
22,380 KB
testcase_36 AC 216 ms
22,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <queue>
#include <string>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <stack>
#include <random>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <assert.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll=long long;
#define read(x) cin>>(x);
#define readll(x) ll (x);cin>>(x);
#define readS(x) string (x);cin>>(x);
#define readvll(x,N) vector<ll> (x)((N));for(int i=0;i<(N);i++){cin>>(x)[i];}
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define rep2d(i,j,H,W) for(ll (i)=0;(i)<(H);(i)++)for(ll (j)=0;(j)<(W);j++)
#define is_in(x,y) (0<=(x) && (x)<H && 0<=(y) && (y)<W)
#define yn {cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
inline ll powll(ll x,ll n){ll r=1;while(n>0){if(n&1){r*=x;};x*=x;n>>=1;};return r;}

int main(){
  ll N,M;
  cin>>N>>M;
  readvll(A,N);
  ll ans=0;
  unordered_map<ll,ll> um;
  unordered_set<ll> us;
  for(ll i=0;i<N;i++){
    A[i]%=M;
    um[A[i]]++;
    us.insert(A[i]);
    if(A[i]){
      us.insert(M-A[i]);
    }
  }
  vector<ll> B;
  B.reserve(2*N);
  for(ll i:us){
    if(2*i<=M){
      B.push_back(i);
    }
  }
  //sort(B.begin(),B.end());
  for(ll i:B){
    if(i==0){
      ans++;
    }else if(2*i==M){
      ans++;
    }else{
      ans+=max(um[i],um[M-i]);
    }
  }
  cout<<ans<<endl;
}

/*
2 4 3 0


*/

0