SHARE
TWEET

Untitled

a guest Jun 1st, 2015 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. class Problem4
  7. {
  8.     static void Main()
  9.     {
  10.         string input = Console.ReadLine();
  11.         string name;
  12.         string country;
  13.         Dictionary<string, Dictionary<string, int>> report = new Dictionary<string, Dictionary<string, int>>();
  14.         while (input != "report")
  15.         {
  16.             string[] split = input.Split(new char[] { '|' });
  17.             name = Regex.Replace(split[0], @"\s{2,}", " ").Trim();
  18.             country = Regex.Replace(split[1], @"\s{2,}", " ").Trim();
  19.             if (!report.ContainsKey(country))
  20.             {
  21.                 report.Add(country, new Dictionary<string, int>());
  22.             }
  23.             if (!report[country].ContainsKey(name))
  24.             {
  25.                 report[country][name] = 0;
  26.             }
  27.             report[country][name]++;
  28.             input = Console.ReadLine();
  29.         }
  30.         var ordered = report.OrderByDescending(x => x.Value.Values.Sum());
  31.         foreach (var item in ordered)
  32.         {
  33.             Console.WriteLine("{0} ({1} participants): {2} wins", item.Key, item.Value.Count, item.Value.Values.Sum());
  34.         }
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top