Advertisement
osman1997

orc

Feb 20th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace exercise1
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int waves = int.Parse(Console.ReadLine());//price of each bullet
  13.  
  14. int total = 0;
  15.  
  16. string[] plate = Console.ReadLine().Split(" ");
  17. string[] warriors = Console.ReadLine().Split(" ");
  18.  
  19. List<int> warrior = new List<int>();
  20. List<int> plates = new List<int>();
  21.  
  22. foreach (var bull in warriors)
  23. {
  24. warrior.Add(int.Parse(bull));
  25. }
  26. foreach (var lo in plate)
  27. {
  28. plates.Add(int.Parse(lo));
  29. }
  30.  
  31. for (int i = 1; i <= waves; i++)
  32. {
  33. if (i % 3 == 0 && i != 0)
  34. {
  35. plates.Add(int.Parse(Console.ReadLine()));
  36. }
  37.  
  38. while (warrior.First() != 0)
  39. {
  40. if (warrior.Last() > plates.First())
  41. {
  42. Console.WriteLine(plates[0]);
  43. warrior[warrior.Count - 1] -= plates[0];
  44. plates.Remove(plates[0]);
  45.  
  46. }
  47. else if (warrior.Last() < plates.First())
  48. {
  49. plates[0] -= warrior.Last();
  50. warrior.Remove(warrior.Last());
  51. }
  52. else
  53. {
  54. plates.Remove(plates[0]);
  55. warrior.Remove(warrior.Last());
  56. }
  57. if (plates.Count == 0 || warrior.Count == 0)
  58. {
  59. break;
  60. }
  61. }
  62.  
  63. if (plates.Count == 0)
  64. {
  65. break;
  66. }
  67. if (waves == i)
  68. {
  69. break;
  70. }
  71.  
  72.  
  73. warriors = Console.ReadLine().Split(" ");
  74.  
  75.  
  76.  
  77. foreach (var bull in warriors)
  78. {
  79. warrior.Add(int.Parse(bull));
  80. }
  81. warrior.Remove(0);
  82. total++;
  83. }
  84.  
  85. if (plates.Count == 0)
  86. {
  87. Console.WriteLine($"The orcs successfully destroyed the Gondor's defense.");
  88.  
  89. StringBuilder sb = new StringBuilder();
  90. sb.Append("Orcs left: ");
  91.  
  92. for (int i = warrior.Count-1; i > -1; i--)
  93. {
  94. sb.Append(warrior[i]);
  95. if (i == 0)
  96. {
  97. }
  98. else
  99. {
  100. sb.Append(", ");
  101. }
  102. }
  103. Console.WriteLine(sb.ToString());
  104. }
  105. else
  106. {
  107. Console.WriteLine($"The people successfully repulsed the orc's attack.");
  108.  
  109. StringBuilder sb = new StringBuilder();
  110. sb.Append("Plates left: ");
  111.  
  112. for (int i = plates.Count - 1; i > -1; i--)
  113. {
  114. sb.Append(plates[i]);
  115. if (i == 0)
  116. {
  117. }
  118. else
  119. {
  120. sb.Append(", ");
  121. }
  122. }
  123. Console.WriteLine(sb.ToString());
  124.  
  125. }
  126. }
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement