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