dobroslav_atanasov

Shellbound

Mar 7th, 2017
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 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.             var input = Console.ReadLine();
  12.             var shellbound = new Dictionary<string, HashSet<long>>();
  13.  
  14.             while (input != "Aggregate")
  15.             {
  16.                 var tokens = input.Split(' ').ToArray();
  17.                 var region = tokens[0];
  18.                 int shell = int.Parse(tokens[1]);
  19.  
  20.                 if (!shellbound.ContainsKey(region))
  21.                 {
  22.                     shellbound[region] = new HashSet<long>();
  23.                 }
  24.  
  25.                 shellbound[region].Add(shell);
  26.  
  27.                 input = Console.ReadLine();
  28.             }
  29.  
  30.            
  31.             foreach (var item in shellbound)
  32.             {
  33.                 long shellSum = item.Value.Sum();
  34.                 double shellCount = item.Value.Count;
  35.                 var giantShell = Math.Ceiling(shellSum - shellSum / shellCount);
  36.                 Console.WriteLine($"{item.Key} -> {string.Join(", ", item.Value)} ({giantShell})");
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment