結果

問題 No.1972 Modulo Set
ユーザー AngrySadEightAngrySadEight
提出日時 2022-06-10 22:02:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 1,153 bytes
コンパイル時間 4,394 ms
コンパイル使用メモリ 228,928 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-04-15 08:50:26
合計ジャッジ時間 7,796 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 15 ms
6,940 KB
testcase_04 AC 22 ms
6,940 KB
testcase_05 AC 24 ms
6,940 KB
testcase_06 AC 37 ms
6,944 KB
testcase_07 AC 58 ms
6,944 KB
testcase_08 AC 27 ms
6,940 KB
testcase_09 AC 5 ms
6,940 KB
testcase_10 AC 21 ms
6,944 KB
testcase_11 AC 56 ms
6,940 KB
testcase_12 AC 11 ms
6,944 KB
testcase_13 AC 6 ms
6,944 KB
testcase_14 AC 7 ms
6,940 KB
testcase_15 AC 71 ms
6,940 KB
testcase_16 AC 74 ms
7,424 KB
testcase_17 AC 24 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 64 ms
7,224 KB
testcase_20 AC 80 ms
7,808 KB
testcase_21 AC 29 ms
6,944 KB
testcase_22 AC 52 ms
7,168 KB
testcase_23 AC 123 ms
13,440 KB
testcase_24 AC 43 ms
7,588 KB
testcase_25 AC 70 ms
9,600 KB
testcase_26 AC 89 ms
6,940 KB
testcase_27 AC 131 ms
13,952 KB
testcase_28 AC 44 ms
7,640 KB
testcase_29 AC 75 ms
9,804 KB
testcase_30 AC 98 ms
12,288 KB
testcase_31 AC 6 ms
6,940 KB
testcase_32 AC 88 ms
11,392 KB
testcase_33 AC 150 ms
15,488 KB
testcase_34 AC 159 ms
15,488 KB
testcase_35 AC 152 ms
15,360 KB
testcase_36 AC 151 ms
15,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(), v.end()
#define mod1 1000000007
#define mod2 998244353
typedef long long ll;

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    map<ll,ll> mp;
    for (ll i = 0; i < N; i++){
        mp[A[i] % M]++;
    }
    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++){
        if (itr->first == 0){
            ans += min(1LL, itr->second);
        }
        else{
            if (M % 2 == 0 && itr->first == M / 2){
                ans += min(1LL, itr->second);
            }
            else{
                if (mp[M - itr->first] == 0){
                    ans += (itr->second);
                }
                else{
                    if (itr->first > M / 2) continue;
                    else ans += max(itr->second, mp[M - (itr->first)]);
                }
                
            }
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}
0