Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Reflection.Metadata.Ecma335;
- namespace Train
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- const int maxPeople = 4;
- int peopleWaiting = int.Parse(Console.ReadLine());
- int[] currentState = Console.ReadLine()
- .Split(" ")
- .Select(int.Parse)
- .ToArray();
- int vagonaSePylni = 0;
- bool isTrue = false;
- int peopleOnTheLift = 0;
- for (int i = 0; i < currentState.Length; i++)
- {
- while (currentState[i] < maxPeople && vagonaSePylni < peopleWaiting)
- {
- currentState[i]++;
- vagonaSePylni++;
- peopleWaiting--;
- isTrue = true;
- }
- }
- peopleOnTheLift += vagonaSePylni;
- if (isTrue && peopleWaiting == peopleOnTheLift)
- {
- {
- Console.WriteLine($"There isn't enough space! {peopleWaiting} people in a queue!{currentState}");
- return;
- }
- }
- foreach (var item in currentState)
- {
- Console.Write(item + " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement