結果

問題 No.1972 Modulo Set
ユーザー rogi52rogi52
提出日時 2022-10-04 02:51:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 209,292 KB
実行使用メモリ 26,448 KB
最終ジャッジ日時 2023-08-28 08:46:42
合計ジャッジ時間 6,531 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,500 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 4 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 6 ms
4,524 KB
testcase_14 AC 7 ms
4,476 KB
testcase_15 WA -
testcase_16 AC 65 ms
10,260 KB
testcase_17 AC 19 ms
5,584 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 56 ms
10,492 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 56 ms
10,304 KB
testcase_23 AC 144 ms
22,648 KB
testcase_24 AC 50 ms
11,296 KB
testcase_25 AC 83 ms
15,432 KB
testcase_26 WA -
testcase_27 AC 152 ms
23,996 KB
testcase_28 AC 56 ms
11,708 KB
testcase_29 AC 93 ms
15,816 KB
testcase_30 AC 130 ms
20,428 KB
testcase_31 AC 7 ms
4,424 KB
testcase_32 AC 119 ms
18,672 KB
testcase_33 AC 176 ms
26,432 KB
testcase_34 AC 179 ms
26,336 KB
testcase_35 AC 181 ms
26,448 KB
testcase_36 AC 180 ms
26,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll N,M; cin >> N >> M;
    map<ll,ll> mp;
    rep(i,N) {
        ll a; cin >> a;
        mp[a % M]++;
    }

    ll ans = 0;
    vector<ll> v;
    for(auto [x, _] : mp) v.push_back(x);
    map<ll,ll> visited;
    for(ll x : v) {
        if(visited.count(x)) continue;
        visited[x] = 1;
        visited[M - x] = 1;
        ans += max(mp[x], mp[M - x]);
    }
    cout << ans << endl;
}
0