Guest User

Untitled

a guest
Jul 20th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 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 inputLine = Console.ReadLine();
  13. if (inputLine == "Aggregate")
  14. {
  15. break;
  16. }
  17. var curent = inputLine
  18. .Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
  19. .ToArray();
  20. string city = curent[0];
  21. var shellSize = int.Parse(curent[1]);
  22. if (!dic.ContainsKey(city))
  23. {
  24. dic[city] = new List<int>();
  25. }
  26. if (!dic[city].Contains(shellSize))
  27. {
  28. dic[city].Add(shellSize);
  29. }
  30. }
  31. foreach (var city in dic)
  32. {
  33. Console.WriteLine("{0} -> {1} ({2})", city.Key, string.Join(", ", city.Value), Math.Ceiling(city.Value.Sum() - city.Value.Average()));
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment