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.RegularExpressions;
- class Problem4
- {
- static void Main()
- {
- string input = Console.ReadLine();
- string name;
- string country;
- Dictionary<string, Dictionary<string, int>> report = new Dictionary<string, Dictionary<string, int>>();
- while (input != "report")
- {
- string[] split = input.Split(new char[] { '|' });
- name = Regex.Replace(split[0], @"\s{2,}", " ").Trim();
- country = Regex.Replace(split[1], @"\s{2,}", " ").Trim();
- if (!report.ContainsKey(country))
- {
- report.Add(country, new Dictionary<string, int>());
- }
- if (!report[country].ContainsKey(name))
- {
- report[country][name] = 0;
- }
- report[country][name]++;
- input = Console.ReadLine();
- }
- var ordered = report.OrderByDescending(x => x.Value.Values.Sum());
- foreach (var item in ordered)
- {
- Console.WriteLine("{0} ({1} participants): {2} wins", item.Key, item.Value.Count, item.Value.Values.Sum());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement