結果

問題 No.1972 Modulo Set
ユーザー atjh16atjh16
提出日時 2022-08-12 16:22:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 139 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 207,884 KB
実行使用メモリ 14,984 KB
最終ジャッジ日時 2023-10-24 01:51:31
合計ジャッジ時間 5,881 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 14 ms
4,348 KB
testcase_04 AC 20 ms
4,348 KB
testcase_05 AC 24 ms
4,348 KB
testcase_06 AC 37 ms
4,348 KB
testcase_07 AC 56 ms
4,348 KB
testcase_08 AC 26 ms
4,348 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 21 ms
4,348 KB
testcase_11 AC 55 ms
4,348 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 6 ms
4,348 KB
testcase_15 AC 62 ms
5,824 KB
testcase_16 AC 69 ms
7,048 KB
testcase_17 AC 24 ms
4,732 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 56 ms
7,220 KB
testcase_20 AC 70 ms
7,696 KB
testcase_21 AC 28 ms
4,836 KB
testcase_22 AC 48 ms
7,096 KB
testcase_23 AC 108 ms
13,092 KB
testcase_24 AC 38 ms
7,588 KB
testcase_25 AC 61 ms
9,588 KB
testcase_26 AC 85 ms
6,332 KB
testcase_27 AC 122 ms
13,700 KB
testcase_28 AC 41 ms
7,760 KB
testcase_29 AC 64 ms
9,804 KB
testcase_30 AC 87 ms
12,060 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 78 ms
11,288 KB
testcase_33 AC 132 ms
14,984 KB
testcase_34 AC 139 ms
14,976 KB
testcase_35 AC 128 ms
14,980 KB
testcase_36 AC 127 ms
14,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long n, m, a, ans;
map<long long, long long> Mp;

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

    for (int i = 0; i < n; i++) {
        cin >> a;
        Mp[a % m]++;
    }

    for (auto j : Mp) {
        long long t = j.first, u = j.second;

        if ((t == 0 || t * 2 == m) && u > 0)
            ans++;
        else  {
            long long w = Mp[m - t];

            if(u > w || (u == w && t < m - t))
                ans += u;
        }
    }

    cout << ans << endl;
}
0