結果

問題 No.1972 Modulo Set
ユーザー kokatsukokatsu
提出日時 2022-06-10 21:34:01
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 204,204 KB
実行使用メモリ 16,944 KB
最終ジャッジ日時 2023-09-04 17:23:25
合計ジャッジ時間 7,260 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 8 ms
4,568 KB
testcase_04 AC 11 ms
4,932 KB
testcase_05 AC 13 ms
5,048 KB
testcase_06 AC 19 ms
7,248 KB
testcase_07 AC 28 ms
12,304 KB
testcase_08 AC 14 ms
6,620 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 11 ms
4,944 KB
testcase_11 AC 27 ms
9,420 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 4 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 35 ms
13,244 KB
testcase_16 AC 39 ms
13,768 KB
testcase_17 AC 14 ms
6,908 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 33 ms
12,708 KB
testcase_20 AC 39 ms
13,476 KB
testcase_21 AC 16 ms
7,180 KB
testcase_22 AC 28 ms
12,156 KB
testcase_23 AC 60 ms
16,792 KB
testcase_24 AC 23 ms
12,096 KB
testcase_25 AC 33 ms
12,928 KB
testcase_26 AC 46 ms
13,204 KB
testcase_27 AC 63 ms
16,944 KB
testcase_28 AC 24 ms
12,136 KB
testcase_29 AC 33 ms
12,908 KB
testcase_30 AC 47 ms
13,220 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 42 ms
13,340 KB
testcase_33 AC 67 ms
13,288 KB
testcase_34 AC 65 ms
15,340 KB
testcase_35 AC 66 ms
13,092 KB
testcase_36 AC 66 ms
14,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long N, M;
    readf("%d %d\n", N, M);

    auto A = readln.chomp.split.to!(long[]);

    long[long] list;
    foreach (a; A) ++list[a%M];

    bool[long] used;
    long res;
    foreach (key, val; list) {
        if (key in used) continue;

        if ((key * 2) % M == 0) {
            ++res;
        }
        else {
            long d = M - key, num = val;
            if (d in list) {
                if (num < list[d]) num = list[d];
                used[d] = true;
            }

            res += num;
        }

        used[key] = true;
    }

    res.writeln;
}
0