Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MovingTarget
- {
- class Program
- {
- static void Main(string[] args)
- {
- var targets = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- string input;
- while ((input = Console.ReadLine()) != "End")
- {
- var tokens = input.Split(' ');
- string command = tokens[0];
- int index = int.Parse(tokens[1]);
- int value = int.Parse(tokens[2]);
- if (command == "Shoot")
- {
- if (index >= 0 && index < targets.Count)
- {
- targets[index] -= value;
- if (targets[index] <= 0)
- {
- targets.RemoveAt(index);
- }
- }
- }
- else if (command == "Add")
- {
- if (index >= 0 && index < targets.Count)
- {
- targets.Insert(index, value);
- }
- else
- {
- Console.WriteLine("Invalid placement!");
- }
- }
- else if (command == "Strike")
- {
- if (index - value >= 0 && index + value < targets.Count)
- {
- targets.RemoveRange(index - value, value * 2 + 1);
- }
- else
- {
- Console.WriteLine("Strike missed!");
- }
- }
- }
- Console.WriteLine(String.Join('|', targets));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement