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