Advertisement
vasilivanov93

Untitled

Mar 13th, 2017
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01.Shellbound
  6. {
  7. public class Shellbound
  8. {
  9. public static void Main()
  10. {
  11. string inputLine = Console.ReadLine();
  12. Dictionary<string, HashSet<int>> regions = new Dictionary<string, HashSet<int>>();
  13.  
  14. while (inputLine != "Aggregate")
  15. {
  16. string[] tokens = inputLine.Split();
  17.  
  18. string region = tokens[0];
  19. int shell = int.Parse(tokens[1]);
  20.  
  21. if (!regions.ContainsKey(region))
  22. {
  23. regions[region] = new HashSet<int>();
  24. }
  25.  
  26. regions[region].Add(shell);
  27.  
  28. inputLine = Console.ReadLine();
  29. }
  30.  
  31. foreach (var regionAndShell in regions)
  32. {
  33. string region = regionAndShell.Key;
  34. HashSet<int> shell = regionAndShell.Value;
  35.  
  36. Console.WriteLine($"{region} -> {string.Join(", ", shell)} ({Math.Ceiling(shell.Sum() - shell.Average())})");
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement