結果
問題 | No.1972 Modulo Set |
ユーザー |
|
提出日時 | 2022-06-10 22:14:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 132 ms / 2,000 ms |
コード長 | 1,174 bytes |
コンパイル時間 | 3,425 ms |
コンパイル使用メモリ | 110,056 KB |
実行使用メモリ | 51,996 KB |
最終ジャッジ日時 | 2024-10-05 01:33:28 |
合計ジャッジ時間 | 5,351 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);}}