結果

問題 No.1972 Modulo Set
ユーザー umimelumimel
提出日時 2022-06-10 21:32:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 172,172 KB
実行使用メモリ 15,488 KB
最終ジャッジ日時 2024-04-15 08:46:49
合計ジャッジ時間 5,348 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 14 ms
6,944 KB
testcase_04 AC 21 ms
6,940 KB
testcase_05 AC 25 ms
6,940 KB
testcase_06 AC 38 ms
6,944 KB
testcase_07 AC 58 ms
6,940 KB
testcase_08 AC 26 ms
6,940 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 21 ms
6,940 KB
testcase_11 AC 56 ms
6,940 KB
testcase_12 AC 11 ms
6,944 KB
testcase_13 AC 6 ms
6,940 KB
testcase_14 AC 7 ms
6,944 KB
testcase_15 AC 68 ms
6,944 KB
testcase_16 AC 78 ms
7,424 KB
testcase_17 AC 26 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 67 ms
7,168 KB
testcase_20 AC 81 ms
7,936 KB
testcase_21 AC 31 ms
6,944 KB
testcase_22 AC 58 ms
7,040 KB
testcase_23 AC 134 ms
13,312 KB
testcase_24 AC 47 ms
7,592 KB
testcase_25 AC 77 ms
9,600 KB
testcase_26 AC 92 ms
6,944 KB
testcase_27 AC 149 ms
13,952 KB
testcase_28 AC 48 ms
7,892 KB
testcase_29 AC 78 ms
9,728 KB
testcase_30 AC 111 ms
12,160 KB
testcase_31 AC 6 ms
6,940 KB
testcase_32 AC 104 ms
11,392 KB
testcase_33 AC 164 ms
15,488 KB
testcase_34 AC 164 ms
15,360 KB
testcase_35 AC 163 ms
15,488 KB
testcase_36 AC 161 ms
15,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1LL << 60;
const ll N_MAX = 2e5;

int main(){
    ll n, m;
    cin >> n >> m;

    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    map<ll, ll> mp;
    rep(i, n) mp[a[i]%m]++;

    ll ans = 0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        if ((*itr).fi == 0 || (*itr).fi * 2 == m){
            ans++;
        }else{
            ans += max((*itr).se, mp[(m-(*itr).fi)%m]);
            (*itr).se = 0;
            mp[(m-(*itr).fi)%m] = 0;
        }
    }

    cout << ans << endl;
}
0