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