結果

問題 No.1972 Modulo Set
ユーザー masayamatumasayamatu
提出日時 2022-06-17 14:37:39
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,717 bytes
コンパイル時間 10,807 ms
コンパイル使用メモリ 168,376 KB
実行使用メモリ 54,784 KB
最終ジャッジ日時 2024-04-17 05:28:04
合計ジャッジ時間 29,010 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
33,408 KB
testcase_01 AC 56 ms
35,584 KB
testcase_02 AC 57 ms
30,208 KB
testcase_03 AC 1,776 ms
36,224 KB
testcase_04 AC 1,150 ms
36,608 KB
testcase_05 AC 591 ms
38,144 KB
testcase_06 TLE -
testcase_07 TLE -
testcase_08 AC 204 ms
37,632 KB
testcase_09 AC 332 ms
32,000 KB
testcase_10 AC 771 ms
36,724 KB
testcase_11 TLE -
testcase_12 AC 1,042 ms
34,688 KB
testcase_13 AC 447 ms
32,512 KB
testcase_14 AC 524 ms
32,512 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (95 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{

    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            var A = Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            for (int i = 0; i < NM[0]; i++)
            {
                A[i] %= NM[1];
            }
            var list = new Dictionary<long, int>();
            for (int i = 0; i < NM[0]; i++)
            {
                if (!list.ContainsKey(A[i]))
                {
                    list.Add(A[i], 1);
                }
                else
                {
                    list[A[i]]++;
                }
            }
            long ans = NM[0];
            for (int i = 0; i < list.Count; i++)
            {
                if (list.ElementAt(i).Key == 0 || (NM[1] % 2 == 0 && list.ElementAt(i).Key == NM[1] / 2))
                {
                    ans -= list.ElementAt(i).Value - 1;
                    list[list.ElementAt(i).Key] = 0;
                }
                else if (list.ContainsKey(NM[1] - list.ElementAt(i).Key))
                {
                    ans -= Math.Min(list[NM[1] - list.ElementAt(i).Key], list.ElementAt(i).Value);
                    list[NM[1] - list.ElementAt(i).Key] = 0;
                    list[list.ElementAt(i).Key] = 0;
                }
            }
            Console.WriteLine(ans);
        }
    }
}
0