using System; using System.Collections.Generic; using System.Linq; // https://yukicoder.me/problems/no/3324 class Program { static string InputPattern = "InputX"; static List GetInputList() { var WillReturn = new List(); if (InputPattern == "Input1") { WillReturn.Add("10 6"); WillReturn.Add("1 2 4 5 6 10"); //3 //1 2 //4 3 //10 1 } else if (InputPattern == "Input2") { WillReturn.Add("5 5"); WillReturn.Add("1 2 3 4 5"); //1 //1 5 } else if (InputPattern == "Input3") { WillReturn.Add("360000 14"); WillReturn.Add("1 2 3 12 13 14 15 16 359995 359996 359997 359998 359999 360000"); //3 //1 3 //12 5 //359995 6 } 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(); } struct ItemInfoDef { internal long Distance; internal long AVal; } static List mItemInfoList = new List(); static void Main() { List InputList = GetInputList(); long[] AArr = GetSplitArr(InputList[1]); for (long I = 0; I <= AArr.GetUpperBound(0); I++) { ItemInfoDef WillAdd; WillAdd.Distance = AArr[I] - I; WillAdd.AVal = AArr[I]; mItemInfoList.Add(WillAdd); } var Query = mItemInfoList.GroupBy(pX => pX.Distance).ToArray(); Console.WriteLine(Query.Count()); foreach (var EachPair in Query) { Console.WriteLine("{0} {1}", EachPair.Min(pX => pX.AVal), EachPair.Count()); } } }