結果

問題 No.1972 Modulo Set
ユーザー kuraraberukuraraberu
提出日時 2022-06-11 04:02:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,007 bytes
コンパイル時間 1,686 ms
コンパイル使用メモリ 181,808 KB
実行使用メモリ 19,664 KB
最終ジャッジ日時 2023-10-21 10:22:10
合計ジャッジ時間 6,090 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 15 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 23 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 57 ms
4,616 KB
testcase_08 AC 24 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 20 ms
4,348 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 7 ms
4,364 KB
testcase_14 AC 7 ms
4,408 KB
testcase_15 WA -
testcase_16 AC 80 ms
8,576 KB
testcase_17 AC 25 ms
5,124 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 82 ms
9,368 KB
testcase_21 AC 31 ms
5,264 KB
testcase_22 AC 56 ms
8,372 KB
testcase_23 AC 150 ms
17,024 KB
testcase_24 AC 49 ms
9,048 KB
testcase_25 AC 77 ms
11,800 KB
testcase_26 AC 99 ms
7,784 KB
testcase_27 AC 154 ms
17,816 KB
testcase_28 AC 48 ms
9,288 KB
testcase_29 AC 71 ms
12,272 KB
testcase_30 AC 123 ms
15,440 KB
testcase_31 AC 6 ms
4,348 KB
testcase_32 AC 110 ms
14,384 KB
testcase_33 AC 190 ms
19,664 KB
testcase_34 AC 183 ms
19,664 KB
testcase_35 AC 183 ms
19,664 KB
testcase_36 AC 175 ms
19,664 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;
    vector<ll> a(N);
    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==M/2){
            ans++;
        }
        else{
            ans+=max(ma[a],ma[M-a]);
        }
    }
    cout<<ans<<endl;
}
0