Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.ShellBound
- {
- class ShellBound
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- Dictionary<string, HashSet<long>> regionData = new Dictionary<string, HashSet<long>>();
- while (input != "Aggregate")
- {
- string[] tokens = input.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- string city = tokens[0];
- long numbers = long.Parse(tokens[1]);
- if (!regionData.ContainsKey(city))
- {
- regionData[city] = new HashSet<long>();
- }
- regionData[city].Add(numbers);
- input = Console.ReadLine();
- }
- foreach (var region in regionData.Keys)
- {
- if (regionData[region].Count != 1)
- {
- Console.WriteLine($"{region} -> {string.Join(", ", regionData[region])} ({regionData[region].Sum() - (regionData[region].Sum() / regionData[region].Count)})");
- }
- else
- {
- Console.WriteLine($"{region} -> {string.Join(", ", regionData[region])} ({regionData[region]})");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement