using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _04.Shellbound { class Program { static void Main(string[] args) { Dictionary> crabShells = new Dictionary>(); string[] inputTokens = Console.ReadLine().Split(' '); while (inputTokens[0] != "Aggregate") { string regionsName = inputTokens[0]; int shellSize = int.Parse(inputTokens[1]); if (!crabShells.ContainsKey(regionsName)) { crabShells.Add(regionsName, new List()); } crabShells[regionsName].Add(shellSize); inputTokens = Console.ReadLine().Split(' '); } foreach (var item in crabShells) { string regionsName = item.Key; List size = item.Value; for (int i = 0; i < size.Count; i++) { for (int j = i + 1; j < size.Count; j++) { if (size[i] == size[j]) { size.RemoveAt(j); i = 0; } } } int sumOfShells = 0; int countOfShells = 0; for (int i = 0; i < size.Count; i++) { sumOfShells += size[i]; countOfShells++; } int giantShell = sumOfShells - (sumOfShells / countOfShells); //int gianShellSize = shell.Value.Sum() - (int)shell.Value.Average(); vmesto gorniq kod Console.WriteLine("{0} -> {1} ({2})", regionsName, string.Join(", ", size), giantShell); } } } }