結果

問題 No.1972 Modulo Set
ユーザー 👑 platinumplatinum
提出日時 2022-06-10 23:39:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 605 bytes
コンパイル時間 2,801 ms
コンパイル使用メモリ 204,220 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-15 08:55:00
合計ジャッジ時間 7,170 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 16 ms
6,944 KB
testcase_04 AC 22 ms
6,940 KB
testcase_05 AC 25 ms
6,944 KB
testcase_06 AC 39 ms
6,944 KB
testcase_07 AC 61 ms
6,940 KB
testcase_08 AC 27 ms
6,944 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 22 ms
6,940 KB
testcase_11 AC 61 ms
6,940 KB
testcase_12 AC 12 ms
6,940 KB
testcase_13 AC 9 ms
6,940 KB
testcase_14 AC 9 ms
6,940 KB
testcase_15 AC 83 ms
8,320 KB
testcase_16 AC 104 ms
10,624 KB
testcase_17 AC 31 ms
6,940 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 100 ms
10,752 KB
testcase_20 AC 113 ms
11,904 KB
testcase_21 AC 37 ms
6,944 KB
testcase_22 AC 85 ms
10,496 KB
testcase_23 AC 200 ms
22,784 KB
testcase_24 AC 73 ms
11,388 KB
testcase_25 AC 120 ms
15,616 KB
testcase_26 AC 114 ms
9,472 KB
testcase_27 AC 213 ms
24,064 KB
testcase_28 AC 78 ms
11,868 KB
testcase_29 AC 127 ms
16,000 KB
testcase_30 AC 179 ms
20,608 KB
testcase_31 AC 9 ms
6,944 KB
testcase_32 AC 163 ms
19,072 KB
testcase_33 AC 254 ms
26,624 KB
testcase_34 AC 245 ms
26,752 KB
testcase_35 AC 241 ms
26,624 KB
testcase_36 AC 248 ms
26,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;

using LL = long long;

int main(){
    int N;
    LL M;
    cin >> N >> M;
    vector<LL> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N) A[i] %= M;
    map<LL,int> mp;
    map<LL,int> used;
    rep(i,N) mp[A[i]]++;
    int ans = 0;
    for(auto itr : mp){
        LL a1 = itr.first;
        if(used[a1]) continue;
        LL a2 = (M - a1) % M;
        if(a1 == a2) ans++;
        else ans += max(mp[a1], mp[a2]);
        used[a1] = 1;
        used[a2] = 1;
    }
    cout << ans << endl;
    
    return 0;
}
0