結果

問題 No.1972 Modulo Set
ユーザー harurunharurun
提出日時 2022-06-10 23:02:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 1,513 bytes
コンパイル時間 4,095 ms
コンパイル使用メモリ 195,536 KB
実行使用メモリ 22,688 KB
最終ジャッジ日時 2024-04-15 08:55:30
合計ジャッジ時間 7,813 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 13 ms
6,944 KB
testcase_04 AC 19 ms
6,940 KB
testcase_05 AC 22 ms
6,940 KB
testcase_06 AC 34 ms
6,940 KB
testcase_07 AC 53 ms
6,944 KB
testcase_08 AC 25 ms
6,944 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 20 ms
6,944 KB
testcase_11 AC 49 ms
6,944 KB
testcase_12 AC 9 ms
6,940 KB
testcase_13 AC 7 ms
6,940 KB
testcase_14 AC 7 ms
6,940 KB
testcase_15 AC 56 ms
6,940 KB
testcase_16 AC 68 ms
8,716 KB
testcase_17 AC 24 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 56 ms
8,756 KB
testcase_20 AC 68 ms
9,544 KB
testcase_21 AC 26 ms
6,940 KB
testcase_22 AC 50 ms
8,748 KB
testcase_23 AC 144 ms
16,804 KB
testcase_24 AC 47 ms
9,164 KB
testcase_25 AC 78 ms
13,048 KB
testcase_26 AC 75 ms
8,640 KB
testcase_27 AC 145 ms
17,548 KB
testcase_28 AC 47 ms
9,140 KB
testcase_29 AC 84 ms
13,260 KB
testcase_30 AC 120 ms
15,436 KB
testcase_31 AC 7 ms
6,944 KB
testcase_32 AC 102 ms
14,568 KB
testcase_33 AC 225 ms
22,572 KB
testcase_34 AC 222 ms
22,632 KB
testcase_35 AC 226 ms
22,616 KB
testcase_36 AC 219 ms
22,688 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