Advertisement
Guest User

Untitled

a guest
Apr 8th, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01._Vapor_Winter_Sale
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var input = Console.ReadLine().Split(", ");
  12. Dictionary<string, double> games = new Dictionary<string, double>();
  13. Dictionary<string, string> contentToGame = new Dictionary<string, string>();
  14.  
  15. for (int i = 0; i < input.Length; i++)
  16. {
  17. if (input[i].Contains('-'))
  18. {
  19. string[] splitToString = input[i].Split('-');
  20. string game = splitToString[0];
  21. double price = double.Parse(splitToString[1]);
  22. if (!games.ContainsKey(game))
  23. {
  24. games[game] = price;
  25.  
  26. }
  27. }
  28. else if (input[i].Contains(':'))
  29. {
  30. string[] splitToString = input[i].Split(':');
  31. string game = splitToString[0];
  32. string dlc = splitToString[1];
  33.  
  34. if (games.ContainsKey(game))
  35. {
  36. contentToGame[game] = dlc;
  37. }
  38. }
  39. }
  40.  
  41. foreach (var game in games.OrderBy(x => x.Value))
  42. {
  43. foreach (var dlc in contentToGame)
  44. {
  45. if (game.Key == dlc.Key)
  46. {
  47. double sum = game.Value;
  48. double gameSum = sum + sum * 0.20;
  49. gameSum -= gameSum * 0.50;
  50. Console.WriteLine($"{game.Key} - {dlc.Value} - {gameSum:F2}");
  51. games.Remove(game.Key);
  52. }
  53.  
  54. }
  55. }
  56. foreach (var dlc in contentToGame)
  57. {
  58. foreach (var game in games.OrderByDescending(x => x.Value))
  59. {
  60. if (!game.Key.Contains(dlc.Key))
  61. {
  62. double gamePrice = game.Value * 0.80;
  63. Console.WriteLine($"{game.Key} - {gamePrice:F2}");
  64. games.Remove(game.Key);
  65. }
  66. }
  67.  
  68. }
  69.  
  70. }
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement