Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         var dic = new Dictionary<string, List<int>>();
  9.  
  10.         while (true)
  11.         {
  12.             var curent = Console.ReadLine().Split();
  13.             if (curent[0] == "Aggregate")
  14.             {
  15.                 break;
  16.             }
  17.             string city = curent[0];
  18.             int shellSize = int.Parse(curent[1]);
  19.  
  20.             if (!dic.ContainsKey(city))
  21.             {
  22.                 dic[city] = new List<int>();
  23.             }
  24.             if (dic[city].Contains(shellSize))
  25.             {
  26.                 dic[city].RemoveAll(item => item == shellSize);
  27.             }
  28.             dic[city].Add(shellSize);
  29.         }
  30.         foreach (var city in dic)
  31.         {
  32.             Console.WriteLine("{0} -> {1} ({2:f0})", city.Key, string.Join(", ", city.Value.Distinct()), city.Value.Sum() - city.Value.Average());
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement