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