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 5"); WillReturn.Add("1 2"); WillReturn.Add("4 3"); } else if (InputPattern == "Input2") { WillReturn.Add("5 6"); WillReturn.Add("5 3"); WillReturn.Add("2 1"); WillReturn.Add("3 4"); WillReturn.Add("5 3"); WillReturn.Add("3 6"); } else if (InputPattern == "Input3") { WillReturn.Add("10 20"); WillReturn.Add("1 1"); WillReturn.Add("5 18"); WillReturn.Add("3 12"); WillReturn.Add("8 5"); WillReturn.Add("6 10"); WillReturn.Add("8 7"); WillReturn.Add("19 6"); WillReturn.Add("20 11"); WillReturn.Add("6 16"); WillReturn.Add("19 16"); } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List InputList = GetInputList(); int[] wkArr = { }; Action SplitAct = pStr => wkArr = pStr.Split(' ').Select(pX => int.Parse(pX)).ToArray(); SplitAct(InputList[0]); int X = wkArr[1]; var ValDict = new Dictionary(); for (int I = 1; I <= X; I++) { ValDict[I] = 0; } foreach (string EachStr in InputList.Skip(1)) { SplitAct(EachStr); int A = wkArr[0]; int B = wkArr[1]; int CurrVal = B; for (int I = 0; I <= B; I++) { int Pos1 = A + I; int Pos2 = A - I; if (1 <= Pos1 && Pos1 <= X) { ValDict[Pos1] = Math.Max(ValDict[Pos1], CurrVal); } if (1 <= Pos2 && Pos2 <= X) { ValDict[Pos2] = Math.Max(ValDict[Pos2], CurrVal); } if (--CurrVal == 0) break; } } Console.WriteLine(IntEnumJoin(" ", ValDict.Values)); } // セパレータとInt型の列挙を引数として、結合したstringを返す static string IntEnumJoin(string pSeparater, IEnumerable pEnum) { string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString()); return string.Join(pSeparater, StrArr); } }