using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; Temoti = long.Parse(Reader.ReadLine()); int boxCount = int.Parse(Reader.ReadLine()); this.BoxList = new long[boxCount]; Total = 0; for(int i=0; ia); if(minVal == minCount) { return this.GetAns(min, q1); } else if(q1Val == minCount) { return this.GetAns(min, q2); } else if(q2Val == minCount) { return this.GetAns(q1, q3); } else if(q3Val == minCount) { return this.GetAns(q2,max); } else { return this.GetAns(q3, max); } } private long GetCount(long target) { if(target * BoxList.Length > Temoti + Total) { return long.MaxValue; } long ans = 0; foreach (long candy in BoxList) { ans += Math.Abs(candy - target); } return ans; } private long[] BoxList; private long Temoti; private long Total; public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 169219876 10 135 24876433 24876476 24876781 24876007 2000 24875934 24876438 24876122 24876474 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }