using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); 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 Dictionary mCntDict = new Dictionary(); static void Main() { List InputList = GetInputList(); long[] wkArr = GetSplitArr(InputList[0]); mOvenCnt = wkArr[0]; mNeedTime = wkArr[2]; mAArr = GetSplitArr(InputList[1]); foreach (long EachA in mAArr) { if (mCntDict.ContainsKey(EachA) == false) { mCntDict[EachA] = 0; } 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 YohuuCnt = 0; foreach (var EachPair in mCntDict) { 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; } }