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 wormsworldpartyizpit30april
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, Dictionary<string,long>> wormsParty = new Dictionary<string, Dictionary<string, long>>();
- bool exist = false;
- string input = Console.ReadLine();
- List<string> names = new List<string>();
- while (input != "quit")
- {
- string[] inputTokens = input.Split(new string[] {" -> "}, StringSplitOptions.RemoveEmptyEntries).ToArray();
- string name = inputTokens[0];
- string team = inputTokens[1];
- long score = long.Parse(inputTokens[2]);
- if (names.Contains(name))
- {
- exist = true;
- }
- if (!exist)
- {
- if (!wormsParty.ContainsKey(team))
- {
- wormsParty.Add(team, new Dictionary<string, long>());
- }
- wormsParty[team].Add(name, score);
- names.Add(name);
- }
- input = Console.ReadLine();
- }
- // logic done output left!
- wormsParty= wormsParty.OrderByDescending(x => x.Value.Sum(y => y.Value))
- .ThenByDescending(x => x.Value.Sum(y => y.Value) / x.Value.Count())
- .ToDictionary(x => x.Key, x => x.Value);
- int count = 1;
- foreach (KeyValuePair<string,Dictionary<string,long>> pair in wormsParty)
- {
- string team = pair.Key;
- Dictionary<string, long> worms = pair.Value;
- long total = worms.Values.Sum();
- Console.WriteLine($"{count}. Team: {team} - {total}");
- foreach (KeyValuePair<string,long> kvp in worms.OrderByDescending(x=>x.Value))
- {
- Console.WriteLine($"###{kvp.Key} : {kvp.Value}");
- }
- count++;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment