結果

問題 No.1972 Modulo Set
ユーザー kuraraberukuraraberu
提出日時 2022-06-11 04:12:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 2,196 ms
コンパイル使用メモリ 174,192 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-15 08:57:12
合計ジャッジ時間 7,326 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 17 ms
5,376 KB
testcase_04 AC 25 ms
5,376 KB
testcase_05 AC 28 ms
5,376 KB
testcase_06 AC 49 ms
5,376 KB
testcase_07 AC 68 ms
5,376 KB
testcase_08 AC 30 ms
5,376 KB
testcase_09 AC 5 ms
5,376 KB
testcase_10 AC 24 ms
5,376 KB
testcase_11 AC 71 ms
5,376 KB
testcase_12 AC 12 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 102 ms
6,400 KB
testcase_16 AC 129 ms
8,192 KB
testcase_17 AC 31 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 103 ms
8,320 KB
testcase_20 AC 135 ms
9,088 KB
testcase_21 AC 37 ms
5,376 KB
testcase_22 AC 86 ms
8,320 KB
testcase_23 AC 235 ms
16,384 KB
testcase_24 AC 71 ms
8,960 KB
testcase_25 AC 118 ms
11,776 KB
testcase_26 AC 144 ms
7,296 KB
testcase_27 AC 245 ms
17,280 KB
testcase_28 AC 75 ms
9,216 KB
testcase_29 AC 129 ms
11,904 KB
testcase_30 AC 184 ms
14,976 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 161 ms
14,080 KB
testcase_33 AC 283 ms
19,072 KB
testcase_34 AC 276 ms
19,200 KB
testcase_35 AC 287 ms
19,200 KB
testcase_36 AC 272 ms
19,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
    ll N,M;
    cin>>N>>M;
    set<ll> se;
    map<ll,ll> ma;
    for(int i=0;i<N;++i){
        ll a;
        cin>>a;
        a%=M;
        ma[a]++;
        a = min(a,M-a);
        se.insert(a);
    }
    ll ans=0;
    for(auto a:se){
        if(a==0||a*2==M){
            ans++;
        }
        else{
            ans+=max(ma[a],ma[M-a]);
        }
    }
    cout<<ans<<endl;
}
0