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.SoftuniBeerPong
- {
- class BeerPong
- {
- static void Main(string[] args)
- {
- string line = Console.ReadLine();
- Dictionary<string, Dictionary<string, long>> contestData = new Dictionary<string, Dictionary<string, long>>();
- while (line != "stop the game")
- {
- string[] tokens = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
- string player = tokens[0];
- string team = tokens[1];
- long point = long.Parse(tokens[2]);
- if (!contestData.ContainsKey(team))
- {
- contestData[team] = new Dictionary<string, long>();
- }
- if (!contestData[team].ContainsKey(player))
- {
- if (contestData[team].Count<3)
- {
- contestData[team][player] = 0;
- }
- }
- if (contestData[team].ContainsKey(player))
- {
- contestData[team][player] = point;
- }
- line = Console.ReadLine();
- }
- int counter = 0;
- foreach (var team in contestData.Where(a=>a.Value.Count>2).OrderByDescending(a=>a.Value.Values.Sum()))
- {
- counter++;
- var key = team.Key;
- var value = team.Value;
- Console.WriteLine($"{counter}. {key}; Players:");
- foreach (var item in value.OrderByDescending(a=>a.Value))
- {
- var player = item.Key;
- var score = item.Value;
- Console.WriteLine($"###{player}: {score}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement