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