結果
問題 |
No.1972 Modulo Set
|
ユーザー |
|
提出日時 | 2022-06-17 13:52:37 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,843 bytes |
コンパイル時間 | 16,461 ms |
コンパイル使用メモリ | 167,724 KB |
実行使用メモリ | 51,712 KB |
最終ジャッジ日時 | 2024-10-08 15:24:33 |
合計ジャッジ時間 | 28,024 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 WA * 11 TLE * 2 -- * 20 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (97 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.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); } } }