Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace TheLift
- {
- class Program
- {
- static void Main(string[] args)
- {
- int people = int.Parse(Console.ReadLine());
- int[] wagons = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- for (int i = 0; i < wagons.Length; i++)
- {
- for (int j = wagons[i]; j < 4; j++)
- {
- if (people == 0)
- {
- break;
- }
- wagons[i]++;
- people--;
- }
- }
- if (wagons[wagons.Length - 1] < 4)
- {
- Console.WriteLine("The lift has empty spots!");
- }
- else if (people > 0)
- {
- Console.WriteLine($"There isn't enough space! {people} people in a queue!");
- }
- Console.WriteLine(string.Join(" ", wagons));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement