結果
問題 |
No.3297 Bake Cookies
|
ユーザー |
![]() |
提出日時 | 2025-10-05 14:30:31 |
言語 | C# (.NET 8.0.404) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,315 bytes |
コンパイル時間 | 10,321 ms |
コンパイル使用メモリ | 171,504 KB |
実行使用メモリ | 292,280 KB |
最終ジャッジ日時 | 2025-10-05 14:32:06 |
合計ジャッジ時間 | 76,356 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 22 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (105 ミリ秒)。 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.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("2 6 2"); WillReturn.Add("1 1 1 1 1 2"); //4 } else if (InputPattern == "Input2") { WillReturn.Add("1 10 100"); WillReturn.Add("1 1 1 1 1 1 1 1 1 1"); //10 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static long[] GetSplitArr(string pStr) { return (pStr == "" ? new string[0] : pStr.Split(' ')).Select(pX => long.Parse(pX)).ToArray(); } static long mOvenCnt; static long mNeedTime; static long[] mAArr; static void Main() { List<string> InputList = GetInputList(); long[] wkArr = GetSplitArr(InputList[0]); mOvenCnt = wkArr[0]; mNeedTime = wkArr[2]; mAArr = GetSplitArr(InputList[1]); long L = 0; long R = long.MaxValue; while (L + 1 < R) { long Mid = R / 2; if (R < long.MaxValue) { Mid = (L + R) / 2; } if (CanAchieve(Mid)) { R = Mid; } else { L = Mid; } } Console.WriteLine(R); } // X分で可能かを返す static bool CanAchieve(long pX) { var CntDict = new Dictionary<long, long>(); foreach (long EachA in mAArr) { if (CntDict.ContainsKey(EachA) == false) { CntDict[EachA] = 0; } CntDict[EachA]++; } long HouwaCnt = 0; long YohuuCnt = 0; foreach (var EachPair in CntDict) { if (EachPair.Value > pX) { HouwaCnt += EachPair.Value - pX; } if (EachPair.Value < pX) { long Buffer = pX - EachPair.Value; YohuuCnt += Buffer / mNeedTime; } } if (HouwaCnt == 0) return true; return HouwaCnt <= YohuuCnt; } }