結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 9 ms
4,376 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 20 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 29 ms
4,380 KB
testcase_12 AC 7 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 46 ms
7,760 KB
testcase_16 AC 61 ms
10,112 KB
testcase_17 AC 20 ms
5,436 KB
testcase_18 WA -
testcase_19 AC 57 ms
10,480 KB
testcase_20 AC 67 ms
11,480 KB
testcase_21 AC 21 ms
5,888 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 145 ms
23,892 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 174 ms
26,348 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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]);
    }
    ans -= mp[0LL];
    ans += 1;
    cout << ans << endl;
}
0