結果

問題 No.3297 Bake Cookies
コンテスト
ユーザー aketijyuuzou
提出日時 2026-11-01 14:40:42
言語 C#
(.NET 10.0.402 + ACL)
コンパイル:
dotnet_c
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 132 ms / 2,000 ms
+ 996µs
コード長 2,437 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,237 ms
コンパイル使用メモリ 171,268 KB
実行使用メモリ 69,468 KB
最終ジャッジ日時 2026-11-01 14:41:00
合計ジャッジ時間 16,708 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (184 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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 if (InputPattern == "Input3") {
            WillReturn.Add("2 2 1");
            WillReturn.Add("1 1");
        }
        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 Dictionary<long, long> mCntDict = new Dictionary<long, long>();

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = GetSplitArr(InputList[0]);
        mOvenCnt = wkArr[0];
        mNeedTime = wkArr[2];

        mAArr = GetSplitArr(InputList[1]);

        for (long I = 1; I <= mOvenCnt; I++) {
            mCntDict[I] = 0;
        }

        foreach (long EachA in mAArr) {
            mCntDict[EachA]++;
        }

        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)
    {
        long HouwaCnt = 0;
        long YoyuuCnt = 0;
        foreach (var EachPair in mCntDict) {
            if (EachPair.Value > pX) {
                HouwaCnt += EachPair.Value - pX;
            }
            if (EachPair.Value < pX) {
                long Buffer = pX - EachPair.Value;
                YoyuuCnt += Buffer / mNeedTime;
            }
        }

        if (HouwaCnt == 0) return true;

        return HouwaCnt <= YoyuuCnt;
    }
}
0