結果

問題 No.1972 Modulo Set
ユーザー 👑 kakel-sankakel-san
提出日時 2022-06-10 22:14:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,174 bytes
コンパイル時間 2,393 ms
コンパイル使用メモリ 70,320 KB
実行使用メモリ 49,424 KB
最終ジャッジ日時 2023-07-27 22:23:32
合計ジャッジ時間 8,226 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
22,820 KB
testcase_01 AC 65 ms
22,720 KB
testcase_02 AC 66 ms
24,888 KB
testcase_03 AC 86 ms
24,952 KB
testcase_04 AC 92 ms
25,092 KB
testcase_05 AC 93 ms
25,996 KB
testcase_06 AC 103 ms
30,996 KB
testcase_07 AC 119 ms
31,692 KB
testcase_08 AC 95 ms
27,648 KB
testcase_09 AC 76 ms
23,408 KB
testcase_10 AC 91 ms
26,948 KB
testcase_11 AC 120 ms
32,148 KB
testcase_12 AC 82 ms
26,064 KB
testcase_13 AC 78 ms
23,776 KB
testcase_14 AC 79 ms
26,016 KB
testcase_15 AC 121 ms
33,164 KB
testcase_16 AC 125 ms
35,212 KB
testcase_17 AC 93 ms
28,080 KB
testcase_18 AC 75 ms
22,952 KB
testcase_19 AC 116 ms
33,328 KB
testcase_20 AC 125 ms
34,992 KB
testcase_21 AC 96 ms
26,908 KB
testcase_22 AC 109 ms
33,452 KB
testcase_23 AC 151 ms
44,800 KB
testcase_24 AC 100 ms
28,372 KB
testcase_25 AC 115 ms
34,004 KB
testcase_26 AC 143 ms
42,412 KB
testcase_27 AC 154 ms
47,920 KB
testcase_28 AC 100 ms
28,408 KB
testcase_29 AC 114 ms
34,000 KB
testcase_30 AC 128 ms
36,496 KB
testcase_31 AC 76 ms
25,516 KB
testcase_32 AC 123 ms
37,328 KB
testcase_33 AC 163 ms
48,340 KB
testcase_34 AC 161 ms
47,388 KB
testcase_35 AC 161 ms
48,384 KB
testcase_36 AC 164 ms
49,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static void Main()
    {
        var c = NList;
        var (n, m) = ((int)c[0], c[1]);
        var a = NList;
        var dic = new Dictionary<long, int>();
        foreach (var ai in a)
        {
            var mod = ai % m;
            if (dic.ContainsKey(mod)) ++dic[mod];
            else dic[mod] = 1;
        }
        var res = 0;
        var delList = new HashSet<long>();
        foreach (var kv in dic)
        {
            if (delList.Contains(kv.Key)) continue;
            if (kv.Key == 0)
            {
                ++res;
                continue;
            }
            else if (kv.Key * 2 == m)
            {
                ++res;
                continue;
            }
            var rev = dic.ContainsKey(m - kv.Key) ? dic[m - kv.Key] : 0;
            res += Math.Max(kv.Value, rev);
            delList.Add(m - kv.Key);
        }
        WriteLine(res);
    }
}
0