Advertisement
BilyanaDer

Key Revolver

Jan 18th, 2020
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Key_Revolver
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int priceBullet = int.Parse(Console.ReadLine());
  12. int sizeGunBarrel = int.Parse(Console.ReadLine());
  13. int[] numBullets = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14. int[] numLucks = Console.ReadLine().Split().Select(int.Parse).ToArray();
  15. int valueIntelligence = int.Parse(Console.ReadLine());
  16.  
  17.  
  18. Stack<int> numBulletsStack = new Stack<int>(numBullets);
  19. Queue<int> numLucksQueue = new Queue<int>(numLucks);
  20.  
  21. while(numBulletsStack.Count != 0)
  22. {
  23. for (int i = 0; i < sizeGunBarrel; i++)
  24. {
  25. if(numBulletsStack.Peek() <= numLucksQueue.Peek())
  26. {
  27. Console.WriteLine("Bang!");
  28. numLucksQueue.Dequeue();
  29. numBulletsStack.Pop();
  30. }
  31. else
  32. {
  33. Console.WriteLine("Ping!");
  34. numBulletsStack.Pop();
  35. }
  36. }
  37. if (numBulletsStack.Count != 0)
  38. {
  39. Console.WriteLine("Reloading!");
  40. if(numLucksQueue.Count == 0)
  41. {
  42. Console.WriteLine($"{numBulletsStack.Count} bullets left. Earned ${valueIntelligence - ((numBullets.Length - numBulletsStack.Count)*priceBullet)}");
  43. return;
  44. }
  45. }
  46.  
  47. }
  48. if(numLucksQueue.Count != 0)
  49. {
  50. Console.WriteLine($"Couldn't get through. Locks left: {numLucksQueue.Count}");
  51. }
  52. else
  53. {
  54. Console.WriteLine($"{numBulletsStack.Count} bullets left. Earned ${valueIntelligence - ((numBullets.Length - numBulletsStack.Count) * priceBullet)}");
  55. }
  56.  
  57.  
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement