Advertisement
Guest User

Untitled

a guest
Nov 5th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 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 (!book.ContainsKey(team))
  36. {
  37. book[team] = new List<Worms>();
  38. }
  39.  
  40. if (!isHere.Contains(name))
  41. {
  42. var total = new Worms
  43. {
  44. Name = name,
  45. Score = score
  46. };
  47. book[team].Add(total);
  48. isHere.Add(name);
  49. }
  50. }
  51.  
  52. long count = 1;
  53. foreach (var item in book.OrderByDescending(a => a.Value.Sum(p => p.Score))
  54. .ThenByDescending(a => a.Value.Sum(p => p.Score) / a.Value.Count))
  55. {
  56. Console.WriteLine($"{count}. Team: {item.Key} - {item.Value.Sum(p => p.Score)}");
  57. foreach (var item2 in item.Value.OrderByDescending(a => a.Score))
  58. {
  59. Console.WriteLine($"###{item2.Name} : {item2.Score}");
  60. }
  61. count++;
  62. }
  63. }
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement