Advertisement
jordan3900

Untitled

Jul 16th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.SoftuniBeerPong
  8. {
  9. class BeerPong
  10. {
  11. static void Main(string[] args)
  12. {
  13. string line = Console.ReadLine();
  14. Dictionary<string, Dictionary<string, long>> contestData = new Dictionary<string, Dictionary<string, long>>();
  15.  
  16. while (line != "stop the game")
  17. {
  18. string[] tokens = line.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
  19. string player = tokens[0];
  20. string team = tokens[1];
  21. long point = long.Parse(tokens[2]);
  22.  
  23. if (!contestData.ContainsKey(team))
  24. {
  25. contestData[team] = new Dictionary<string, long>();
  26. }
  27. if (!contestData[team].ContainsKey(player))
  28. {
  29. if (contestData[team].Count<3)
  30. {
  31. contestData[team][player] = 0;
  32. }
  33.  
  34. }
  35. if (contestData[team].ContainsKey(player))
  36. {
  37. contestData[team][player] = point;
  38. }
  39.  
  40. line = Console.ReadLine();
  41. }
  42. int counter = 0;
  43. foreach (var team in contestData.Where(a=>a.Value.Count>2).OrderByDescending(a=>a.Value.Values.Sum()))
  44. {
  45.  
  46. counter++;
  47. var key = team.Key;
  48. var value = team.Value;
  49. Console.WriteLine($"{counter}. {key}; Players:");
  50. foreach (var item in value.OrderByDescending(a=>a.Value))
  51. {
  52. var player = item.Key;
  53. var score = item.Value;
  54. Console.WriteLine($"###{player}: {score}");
  55. }
  56.  
  57.  
  58.  
  59. }
  60.  
  61.  
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement