結果
| 問題 |
No.1972 Modulo Set
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-06-17 14:37:39 |
| 言語 | C# (.NET 8.0.404) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,717 bytes |
| コンパイル時間 | 11,936 ms |
| コンパイル使用メモリ | 165,268 KB |
| 実行使用メモリ | 54,784 KB |
| 最終ジャッジ日時 | 2024-10-08 16:56:45 |
| 合計ジャッジ時間 | 30,286 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 4 -- * 21 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (132 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]]++;
}
}
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);
}
}
}