Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 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 Problem_4___Worms_World_Party
  8. {
  9. class Program
  10. {
  11. class Worms
  12. {
  13. public string Name { get; set; }
  14. public long Score { get; set; }
  15. }
  16.  
  17. static void Main(string[] args)
  18. {
  19. var book = new Dictionary<string, List<Worms>>();
  20. var isHere = new List<string>();
  21. while (true)
  22. {
  23. var input = Console.ReadLine();
  24.  
  25. if (input == "quit")
  26. {
  27. break;
  28. }
  29.  
  30. var currentWorm = input.Split(new string[] { " -> " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
  31. var team = currentWorm[1];
  32. var name = currentWorm[0];
  33. var score = long.Parse(currentWorm[2]);
  34.  
  35. if (!isHere.Contains(name))
  36. {
  37. if (!book.ContainsKey(team))
  38. {
  39. book[team] = new List<Worms>();
  40. }
  41. var total = new Worms
  42. {
  43. Name = name,
  44. Score = score
  45. };
  46. book[team].Add(total);
  47. isHere.Add(name);
  48.  
  49. }
  50. isHere.Add(name);
  51. }
  52.  
  53. long count = 1;
  54.  
  55. foreach (var item in book.OrderByDescending(a => a.Value.Sum(p => p.Score))
  56. .ThenByDescending(a => a.Value.Sum(p => p.Score) / a.Value.Count()))
  57. {
  58. Console.WriteLine($"{count}. Team: {item.Key} - {item.Value.Sum(p => p.Score)}");
  59. foreach (var item2 in item.Value.OrderByDescending(a => a.Score))
  60. {
  61. Console.WriteLine($"###{item2.Name} : {item2.Score}");
  62. }
  63. count++;
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement