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 tourists = int.Parse(Console.ReadLine());
- int[] lift = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int capacity = (lift.Length * 4) - lift.Sum();
- if (tourists == 0)
- {
- Console.WriteLine("The lift has empty spots!");
- Console.WriteLine(String.Join(" ", lift));
- return;
- }
- for (int i = 0; i < lift.Length; i++)
- {
- int maxWagonCapacity = 4 - lift[i];
- if (maxWagonCapacity > 0 && tourists > 0 && capacity > 0)
- {
- for (int j = 0; j < maxWagonCapacity; j++)
- {
- lift[i]++;
- tourists--;
- if (tourists == 0 || tourists == capacity)
- {
- break;
- }
- }
- }
- }
- if (tourists == 0)
- {
- Console.WriteLine("The lift has empty spots!");
- Console.WriteLine(String.Join(" ", lift));
- }
- else
- {
- Console.WriteLine($"There isn't enough space! {tourists} people in a queue!");
- Console.WriteLine(String.Join(" ", lift));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement