Guest User

Untitled

a guest
Oct 21st, 2017
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 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 P10SerbianUnleashed
  8. {
  9. class P10SerbianUnleashed
  10. {
  11. static void Main(string[] args)
  12. {
  13. Dictionary<string, Dictionary<string, int>> venueDict = new Dictionary<string, Dictionary<string, int>>();
  14. string input = Console.ReadLine();
  15. while (input!="End")
  16. {
  17. if (!input.Contains(" @"))
  18. {
  19. input = Console.ReadLine();
  20. continue;
  21. }
  22. string[] singerInfo = input.Split(' ');
  23. int ticketCount = 0;
  24. int ticketPrice = 0;
  25. try
  26. {
  27. ticketCount = int.Parse(singerInfo[singerInfo.Length - 1]);
  28. ticketPrice = int.Parse(singerInfo[singerInfo.Length - 2]);
  29. }
  30. catch (Exception)
  31. {
  32. input = Console.ReadLine();
  33. continue;
  34. }
  35. string singer = "";
  36. string venue = "";
  37. for (int i = 0; i <= singerInfo.Length-3; i++)
  38. {
  39. if (!singerInfo[i].Contains("@"))
  40. {
  41. singer = singer + singerInfo[i] + " ";
  42. }
  43. else
  44. {
  45. for (int j = i; j <= singerInfo.Length - 3; j++)
  46. {
  47. venue = venue + singerInfo[j] + " ";
  48. }
  49. break;
  50. }
  51. }
  52. singer = singer.Remove(singer.Length - 1, 1);
  53. venue = venue.Remove(venue.Length - 1, 1).Remove(0, 1);
  54. if (!venueDict.ContainsKey(venue))
  55. {
  56. venueDict.Add(venue, new Dictionary<string, int>());
  57. venueDict[venue].Add(singer, ticketCount*ticketPrice);
  58. }
  59. else if (!venueDict[venue].ContainsKey(singer))
  60. {
  61. venueDict[venue].Add(singer, ticketCount * ticketPrice);
  62. }
  63. else
  64. {
  65. venueDict[venue][singer] += ticketCount * ticketPrice;
  66. }
  67. input = Console.ReadLine();
  68. }
  69. foreach (var venue in venueDict)
  70. {
  71. Console.WriteLine(venue.Key);
  72. foreach (var singer in venue.Value.Distinct().OrderByDescending(x => x.Value))
  73. {
  74. Console.WriteLine($"# {singer.Key} -> {singer.Value}");
  75. }
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment