Advertisement
YavorJS

Trophon the Grumpy Cat - 80%

Sep 25th, 2016
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.77 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Trophon
  5. {
  6. static void Main()
  7. {
  8. long[] priceRatings = Console.ReadLine().Split().Select(long.Parse).ToArray();
  9. int entryPoint = int.Parse(Console.ReadLine());
  10. string priceRating = Console.ReadLine();
  11. string typeOfRating = Console.ReadLine();
  12. long leftDamage = 0;
  13. long rightDamage = 0;
  14. if (priceRating == "cheap")
  15. {
  16. if (typeOfRating == "positive")
  17. {
  18. for (int i = 0; i < entryPoint; i++)
  19. {
  20. if (priceRatings[i] > 0 && priceRatings[i] < priceRatings[entryPoint]) leftDamage += priceRatings[i];
  21. }
  22. for (int i = entryPoint + 1; i < priceRatings.Length - 1; i++)
  23. {
  24. if (priceRatings[i] > 0 && priceRatings[i] < priceRatings[entryPoint]) rightDamage += priceRatings[i];
  25. }
  26. }
  27. else if (typeOfRating == "negative")
  28. {
  29. for (int i = 0; i < entryPoint; i++)
  30. {
  31. if (priceRatings[i] < 0 && priceRatings[i] < priceRatings[entryPoint]) leftDamage += priceRatings[i];
  32. }
  33. for (int i = entryPoint + 1; i < priceRatings.Length - 1; i++)
  34. {
  35. if (priceRatings[i] < 0 && priceRatings[i] < priceRatings[entryPoint]) rightDamage += priceRatings[i];
  36. }
  37. }
  38. else if (typeOfRating == "all")
  39. {
  40. for (int i = 0; i < entryPoint; i++)
  41. {
  42. if (priceRatings[i] < priceRatings[entryPoint]) leftDamage += priceRatings[i];
  43. }
  44. for (int i = entryPoint + 1; i < priceRatings.Length - 1; i++)
  45. {
  46. if (priceRatings[i] < priceRatings[entryPoint]) rightDamage += priceRatings[i];
  47. }
  48. }
  49. }
  50. else if (priceRating == "expensive")
  51. {
  52. if (typeOfRating == "positive")
  53. {
  54. for (int i = 0; i < entryPoint; i++)
  55. {
  56. if (priceRatings[i] > 0 && priceRatings[i] >= priceRatings[entryPoint]) leftDamage += priceRatings[i];
  57. }
  58. for (int i = entryPoint + 1; i < priceRatings.Length - 1; i++)
  59. {
  60. if (priceRatings[i] > 0 && priceRatings[i] >= priceRatings[entryPoint]) rightDamage += priceRatings[i];
  61. }
  62. }
  63. else if (typeOfRating == "negative")
  64. {
  65. for (int i = 0; i < entryPoint; i++)
  66. {
  67. if (priceRatings[i] < 0 && priceRatings[i] >= priceRatings[entryPoint]) leftDamage += priceRatings[i];
  68. }
  69. for (int i = entryPoint + 1; i < priceRatings.Length - 1; i++)
  70. {
  71. if (priceRatings[i] < 0 && priceRatings[i] >= priceRatings[entryPoint]) rightDamage += priceRatings[i];
  72. }
  73. }
  74. else if (typeOfRating == "all")
  75. {
  76. for (int i = 0; i < entryPoint; i++)
  77. {
  78. if (priceRatings[i] >= priceRatings[entryPoint]) leftDamage += priceRatings[i];
  79. }
  80. for (int i = entryPoint + 1; i < priceRatings.Length - 1; i++)
  81. {
  82. if (priceRatings[i] >= priceRatings[entryPoint]) rightDamage += priceRatings[i];
  83. }
  84. }
  85. }
  86.  
  87. if (leftDamage >= rightDamage)
  88. {
  89. Console.WriteLine($"Left - {leftDamage}");
  90. }
  91. else
  92. {
  93. Console.WriteLine($"Right - {rightDamage}");
  94. }
  95.  
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement