Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Key_Revolver
- {
- class Program
- {
- static void Main(string[] args)
- {
- int priceBullet = int.Parse(Console.ReadLine());
- int sizeGunBarrel = int.Parse(Console.ReadLine());
- int[] numBullets = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int[] numLucks = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int valueIntelligence = int.Parse(Console.ReadLine());
- Stack<int> numBulletsStack = new Stack<int>(numBullets);
- Queue<int> numLucksQueue = new Queue<int>(numLucks);
- while(numBulletsStack.Count != 0)
- {
- for (int i = 0; i < sizeGunBarrel; i++)
- {
- if(numBulletsStack.Peek() <= numLucksQueue.Peek())
- {
- Console.WriteLine("Bang!");
- numLucksQueue.Dequeue();
- numBulletsStack.Pop();
- }
- else
- {
- Console.WriteLine("Ping!");
- numBulletsStack.Pop();
- }
- }
- if (numBulletsStack.Count != 0)
- {
- Console.WriteLine("Reloading!");
- if(numLucksQueue.Count == 0)
- {
- Console.WriteLine($"{numBulletsStack.Count} bullets left. Earned ${valueIntelligence - ((numBullets.Length - numBulletsStack.Count)*priceBullet)}");
- return;
- }
- }
- }
- if(numLucksQueue.Count != 0)
- {
- Console.WriteLine($"Couldn't get through. Locks left: {numLucksQueue.Count}");
- }
- else
- {
- Console.WriteLine($"{numBulletsStack.Count} bullets left. Earned ${valueIntelligence - ((numBullets.Length - numBulletsStack.Count) * priceBullet)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement