Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ShootForTheWin
- {
- class Program
- {
- static void Main(string[] args)
- {
- var targets = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- int index, shotTargets = 0;
- string command;
- while ((command = Console.ReadLine()) != "End")
- {
- index = int.Parse(command);
- if (index >= 0 && index < targets.Count)
- {
- for (int i = 0; i < targets.Count; i++)
- {
- if (targets[i] != -1 && index != i)
- {
- if (targets[i] > targets[index])
- {
- targets[i] -= targets[index];
- }
- else
- {
- targets[i] += targets[index];
- }
- }
- }
- targets[index] = -1;
- shotTargets++;
- }
- }
- Console.WriteLine($"Shot targets: {shotTargets} -> {String.Join(' ', targets)}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement