Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _01.Shellbound
- {
- public class Shellbound
- {
- public static void Main()
- {
- string inputLine = Console.ReadLine();
- Dictionary<string, HashSet<int>> regions = new Dictionary<string, HashSet<int>>();
- while (inputLine != "Aggregate")
- {
- string[] tokens = inputLine.Split();
- string region = tokens[0];
- int shell = int.Parse(tokens[1]);
- if (!regions.ContainsKey(region))
- {
- regions[region] = new HashSet<int>();
- }
- regions[region].Add(shell);
- inputLine = Console.ReadLine();
- }
- foreach (var regionAndShell in regions)
- {
- string region = regionAndShell.Key;
- HashSet<int> shell = regionAndShell.Value;
- Console.WriteLine($"{region} -> {string.Join(", ", shell)} ({Math.Ceiling(shell.Sum() - shell.Average())})");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement