Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text;
- using System.Numerics;
- public class Program
- {
- public static void Main()
- {
- int bulletPrice = int.Parse(Console.ReadLine());
- int barrelSize = int.Parse(Console.ReadLine());
- int[] bulletsInput = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int[] locksInput = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int money = int.Parse(Console.ReadLine());
- Stack<int>bullets = new Stack<int>(bulletsInput);
- Queue<int>locks = new Queue<int>(locksInput);
- int allBullets = bullets.Count;
- int currShot =0;
- while(bullets.Any() && locks.Any())
- {
- int currBullet = bullets.Pop();
- int currLock = locks.Peek();
- if(currBullet<=currLock)
- {
- Console.WriteLine("Bang!");
- locks.Dequeue();
- }
- else
- {
- Console.WriteLine("Ping!");
- }
- currShot++;
- if(currShot==barrelSize && bullets.Count>0)
- {
- Console.WriteLine("Reloading!");
- currShot=0;
- }
- }
- if(locks.Any())
- {
- Console.WriteLine("Couldn't get through. Locks left: {0}",locks.Count);
- }
- else
- {
- int bulletsUsed = allBullets - bullets.Count;
- int moneyUsed = bulletsUsed * bulletPrice;
- int moneyLeft = money - moneyUsed;
- Console.WriteLine("{0} bullets left. Earned ${1}",bullets.Count,moneyLeft);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement