結果

問題 No.1972 Modulo Set
ユーザー masayamatumasayamatu
提出日時 2022-06-17 13:52:37
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,843 bytes
コンパイル時間 15,066 ms
コンパイル使用メモリ 168,200 KB
実行使用メモリ 51,584 KB
最終ジャッジ日時 2024-04-17 04:40:16
合計ジャッジ時間 24,808 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
34,284 KB
testcase_01 AC 57 ms
36,352 KB
testcase_02 AC 58 ms
30,848 KB
testcase_03 WA -
testcase_04 AC 342 ms
37,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
testcase_16 TLE -
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 を復元しました (100 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]]++;
                }
            }
            list = list.OrderBy(a => a.Key).ToDictionary(a => a.Key, a => a.Value);
            long ans = NM[0];
            int idx = 0;
            if (list.Count % 2 == 0)
            {
                idx = list.Count / 2 - 1;
            }
            else
            {
                idx = list.Count / 2;
            }
            for (int i = 0; i <= idx; i++)
            {
                if (list.ElementAt(i).Key == 0 || (NM[1] % 2 == 0 && list.ElementAt(i).Key == NM[0] / 2))
                {
                    ans -= list.ElementAt(i).Value - 1;
                }
                else if (list.ContainsKey(NM[1] - list.ElementAt(i).Key))
                {
                    ans -= Math.Min(list[NM[1] - list.ElementAt(i).Key], list.ElementAt(i).Value);
                }
            }
            Console.WriteLine(ans);
        }
    }
}
0