fork download
  1. namespace _10.Сръбско_Unleashed
  2. {
  3. using System;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6. using System.Text.RegularExpressions;
  7.  
  8. public class Program
  9. {
  10. public static void Main()
  11. {
  12. var input = Console.ReadLine();
  13.  
  14. var singersConcertData = new Dictionary<string, Dictionary<string, long>>();
  15.  
  16. AnotherTry:
  17. try
  18. {
  19. while (input != "End")
  20. {
  21. var singerUnsplitted = Regex.Split(input, " @").ToList();
  22. var singer = singerUnsplitted[0];
  23.  
  24. var venueUnsplittedFirst = singerUnsplitted[1].ToList();
  25. venueUnsplittedFirst.RemoveAll(char.IsDigit);
  26. var venueUnsplittedSecond = string.Concat(venueUnsplittedFirst);
  27. var venueUnsplittedThird = Regex.Split(venueUnsplittedSecond, " ").ToList();
  28. var venue = venueUnsplittedThird[0];
  29.  
  30. var takeNumbers = input.Split(' ').Reverse().ToList();
  31. var thicketPrice = long.Parse(takeNumbers[0]);
  32. var thicketCount = long.Parse(takeNumbers[1]);
  33. var thicketResult = thicketCount * thicketPrice;
  34.  
  35. if (!singersConcertData.ContainsKey(venue))
  36. {
  37. singersConcertData[venue] = new Dictionary<string, long>();
  38. }
  39.  
  40. else if (singersConcertData[venue].ContainsKey(singer))
  41. {
  42. thicketResult += singersConcertData[venue][singer];
  43. }
  44.  
  45. singersConcertData[venue][singer] = thicketResult;
  46. input = Console.ReadLine();
  47. }
  48. }
  49.  
  50. catch (Exception)
  51. {
  52. input = Console.ReadLine();
  53. goto AnotherTry;
  54. }
  55.  
  56. foreach (var venue in singersConcertData)
  57. {
  58. Console.WriteLine(venue.Key);
  59.  
  60. foreach (var singerMoneyEarn in venue.Value.OrderByDescending(x => x.Value))
  61. {
  62. Console.WriteLine($"# {singerMoneyEarn.Key} -> {singerMoneyEarn.Value}");
  63. }
  64. }
  65. }
  66. }
  67. }
Time limit exceeded #stdin #stdout 5s 142528KB
stdin
Standard input is empty
stdout
Standard output is empty