Advertisement
damyan91

Untitled

Feb 4th, 2017
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 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 _10.Сръбско_Unleashed
  8. {
  9. public class Program
  10. {
  11. static void Main()
  12. {
  13. var concertsInfo = new Dictionary<string, Dictionary<string, long>>();
  14.  
  15. string input = Console.ReadLine();
  16.  
  17. while (input != "End")
  18. {
  19. List<string> splitedInfo = input.Split(new char[] { '@' }).ToList();
  20.  
  21. string singer = splitedInfo[0];
  22.  
  23. string venueAndtickets = splitedInfo[1];
  24.  
  25. List<string> splitVenueAndTickets = venueAndtickets.Split(new char[] { ' ' }).ToList();
  26.  
  27. int ticketsPrice;
  28. bool isCorrect = int.TryParse(splitVenueAndTickets[splitVenueAndTickets.Count - 2], out ticketsPrice);
  29.  
  30. int ticketsCount;
  31. bool ticket = int.TryParse(splitVenueAndTickets.Last(), out ticketsCount);
  32.  
  33. splitVenueAndTickets.RemoveRange(splitVenueAndTickets.Count - 2, 2);
  34. string venue = string.Join(" ", splitVenueAndTickets);
  35.  
  36. if (isCorrect && ticket && singer.Last() == ' ')
  37. {
  38. long totalMoney = ticketsPrice * ticketsCount;
  39.  
  40. if (!concertsInfo.ContainsKey(venue))
  41. {
  42. concertsInfo.Add(venue, new Dictionary<string, long>());
  43. }
  44.  
  45. if (!concertsInfo[venue].ContainsKey(singer))
  46. {
  47. concertsInfo[venue].Add(singer, 0);
  48. }
  49.  
  50. concertsInfo[venue][singer] += totalMoney;
  51. }
  52.  
  53. input = Console.ReadLine();
  54. }
  55.  
  56. foreach (var venue in concertsInfo)
  57. {
  58. Console.WriteLine($"{venue.Key}");
  59.  
  60. foreach (var singer in venue.Value.OrderByDescending(x => x.Value))
  61. {
  62. Console.WriteLine($"# {singer.Key}-> {singer.Value}");
  63. }
  64. }
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement