結果
| 問題 | 
                            No.1972 Modulo Set
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-06-17 13:42:02 | 
| 言語 | C#  (.NET 8.0.404)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,640 bytes | 
| コンパイル時間 | 17,996 ms | 
| コンパイル使用メモリ | 167,808 KB | 
| 実行使用メモリ | 60,964 KB | 
| 最終ジャッジ日時 | 2024-10-08 15:01:57 | 
| 合計ジャッジ時間 | 29,924 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 1 WA * 11 TLE * 2 -- * 20 | 
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (99 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/
ソースコード
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.ContainsKey(NM[1] - list.ElementAt(i).Key))
                {
                    ans -= Math.Min(list[NM[1] - list.ElementAt(i).Key], list.ElementAt(i).Value);
                }
            }
            Console.WriteLine(ans);
        }
    }
}