Advertisement
jordan3900

Untitled

Jul 20th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.ShellBound
  8. {
  9. class ShellBound
  10. {
  11. static void Main(string[] args)
  12. {
  13. string input = Console.ReadLine();
  14. Dictionary<string, HashSet<long>> regionData = new Dictionary<string, HashSet<long>>();
  15. while (input != "Aggregate")
  16. {
  17. string[] tokens = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  18. string city = tokens[0];
  19. long numbers = long.Parse(tokens[1]);
  20.  
  21. if (!regionData.ContainsKey(city))
  22. {
  23. regionData[city] = new HashSet<long>();
  24. }
  25. regionData[city].Add(numbers);
  26. input = Console.ReadLine();
  27. }
  28. foreach (var region in regionData.Keys)
  29. {
  30. if (regionData[region].Count != 1)
  31. {
  32. Console.WriteLine($"{region} -> {string.Join(", ", regionData[region])} ({regionData[region].Sum() - (regionData[region].Sum() / regionData[region].Count)})");
  33. }
  34. else
  35. {
  36. Console.WriteLine($"{region} -> {string.Join(", ", regionData[region])} ({regionData[region]})");
  37. }
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement