Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 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 ConsoleApp5
  8. {
  9. class MaxSequenceOfEqualElement
  10. {
  11. static void Main(string[] args)
  12.  
  13. {
  14. Dictionary<string, Dictionary<string, ulong>> performerInfo = new Dictionary<string, Dictionary<string, ulong>>();
  15. string performer = "";
  16. string venue = "";
  17. ulong ticketPrice = 0;
  18. ulong ticketCount = 0;
  19. ulong totalCurrentProfit = 0;
  20.  
  21. while (true)
  22. {
  23. string input = Console.ReadLine();
  24.  
  25. if (input.StartsWith("End"))
  26. {
  27. break;
  28. }
  29.  
  30. string[] checkInvalid = input.Split(' ',StringSplitOptions.RemoveEmptyEntries).ToArray();
  31.  
  32. if (checkInvalid.Length < 4)
  33. {
  34. continue;
  35. }
  36.  
  37. string[] arr = input.Split('@').ToArray();
  38.  
  39. performer = arr[0];
  40.  
  41. string[] venuePriceTickets = arr[1].Split(' ', StringSplitOptions.RemoveEmptyEntries).ToArray();
  42.  
  43.  
  44. ticketCount = ulong.Parse(venuePriceTickets[venuePriceTickets.Length - 1]);
  45. ticketPrice = ulong.Parse(venuePriceTickets[venuePriceTickets.Length - 2]);
  46. totalCurrentProfit = ticketPrice * ticketCount;
  47.  
  48. string[] venueArr = venuePriceTickets.SkipLast(2).ToArray();
  49.  
  50. venue = string.Join(" ", venueArr);
  51.  
  52. if (performerInfo.ContainsKey(venue))
  53. {
  54. if (performerInfo[venue].ContainsKey(performer))
  55. {
  56. performerInfo[venue][performer] += totalCurrentProfit;
  57. }
  58. else
  59. {
  60. performerInfo[venue].Add(performer, totalCurrentProfit);
  61. }
  62. }
  63. else
  64. {
  65. Dictionary<string, ulong> currentDict = new Dictionary<string, ulong>();
  66. currentDict.Add(performer, totalCurrentProfit);
  67. performerInfo.Add(venue, currentDict);
  68. }
  69.  
  70. }
  71.  
  72. foreach (var kvp in performerInfo)
  73. {
  74. Console.WriteLine(kvp.Key);
  75.  
  76. foreach (var name in kvp.Value.OrderByDescending(x=>x.Value))
  77. {
  78. Console.WriteLine($"# {name.Key} -> {name.Value}");
  79. }
  80. }
  81. }
  82. }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement