Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace HeartDelivery
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split("@", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- string[] command = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
- int currentIndex = 0;
- int lastPosition = 0;
- while (command[0] != "Love!")
- {
- int jumpLength = int.Parse(command[1]);
- int steps = currentIndex + jumpLength;
- if (steps >= array.Length)
- {
- steps = 0;
- if (array[steps] != 0)
- {
- array[steps] -= 2;
- currentIndex = steps;
- lastPosition = currentIndex;
- if (array[steps] == 0)
- {
- Console.WriteLine($"Place {steps} has Valentine's day.");
- }
- }
- else
- {
- Console.WriteLine($"Place {steps} already had Valentine's day.");
- }
- }
- else
- {
- if (array[steps] == 0)
- {
- Console.WriteLine($"Place {steps} already had Valentine's day.");
- }
- else
- {
- array[steps] -= 2;
- currentIndex = steps;
- lastPosition = currentIndex;
- if (array[steps] == 0)
- {
- Console.WriteLine($"Place {steps} has Valentine's day.");
- }
- }
- }
- command = Console.ReadLine().Split().ToArray();
- }
- Console.WriteLine($"Cupid's last position was {lastPosition}.");
- Console.WriteLine(array.All(i => i == 0) ? "Mission was successful." : $"Cupid has failed {array.Count(i => i > 0)} places.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement