結果

問題 No.1972 Modulo Set
ユーザー 👑 kakel-sankakel-san
提出日時 2022-06-10 22:14:38
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,174 bytes
コンパイル時間 3,081 ms
コンパイル使用メモリ 114,940 KB
実行使用メモリ 52,252 KB
最終ジャッジ日時 2024-04-15 08:51:31
合計ジャッジ時間 6,719 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
26,244 KB
testcase_01 AC 37 ms
26,416 KB
testcase_02 AC 35 ms
26,496 KB
testcase_03 AC 52 ms
30,744 KB
testcase_04 AC 58 ms
28,416 KB
testcase_05 AC 61 ms
29,732 KB
testcase_06 AC 71 ms
32,460 KB
testcase_07 AC 88 ms
34,940 KB
testcase_08 AC 63 ms
29,300 KB
testcase_09 AC 41 ms
29,044 KB
testcase_10 AC 57 ms
28,420 KB
testcase_11 AC 88 ms
35,656 KB
testcase_12 AC 49 ms
29,868 KB
testcase_13 AC 44 ms
27,368 KB
testcase_14 AC 45 ms
29,628 KB
testcase_15 AC 91 ms
38,616 KB
testcase_16 AC 94 ms
38,632 KB
testcase_17 AC 58 ms
31,608 KB
testcase_18 AC 39 ms
28,536 KB
testcase_19 AC 84 ms
36,948 KB
testcase_20 AC 97 ms
38,384 KB
testcase_21 AC 63 ms
30,080 KB
testcase_22 AC 77 ms
35,116 KB
testcase_23 AC 125 ms
49,564 KB
testcase_24 AC 71 ms
29,624 KB
testcase_25 AC 83 ms
37,700 KB
testcase_26 AC 114 ms
46,120 KB
testcase_27 AC 126 ms
50,456 KB
testcase_28 AC 69 ms
29,748 KB
testcase_29 AC 83 ms
37,516 KB
testcase_30 AC 99 ms
40,004 KB
testcase_31 AC 43 ms
27,396 KB
testcase_32 AC 93 ms
38,732 KB
testcase_33 AC 139 ms
50,200 KB
testcase_34 AC 139 ms
50,080 KB
testcase_35 AC 138 ms
52,252 KB
testcase_36 AC 140 ms
52,252 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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