Advertisement
Iskrenov84

02.The Lift

Feb 15th, 2022
879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace P2._TheLift
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int peopleWaiting = int.Parse(Console.ReadLine());
  11.             int[] lift = Console.ReadLine()
  12.                 .Split(' ')
  13.                 .Select(int.Parse)
  14.                 .ToArray();
  15.  
  16.             for (int i = 0; i < lift.Length; i++)
  17.             {
  18.                 for (int k = lift[i]; k < 4; k++)
  19.                 {
  20.                     if (peopleWaiting == 0 && lift[i] < 4)
  21.                     {
  22.                         Console.WriteLine($"The lift has empty spots!\n{string.Join(" ", lift)}");
  23.                     }
  24.  
  25.                     if (lift[i] == 4)
  26.                     {
  27.                         break;
  28.                     }
  29.  
  30.                     lift[i]++;
  31.                     peopleWaiting--;
  32.  
  33.                 }
  34.             }
  35.             if (peopleWaiting == 0)
  36.             {
  37.                 Console.WriteLine(string.Join(" ", lift));
  38.             }
  39.             if (peopleWaiting > 0)
  40.             {
  41.                 Console.WriteLine($"There isn't enough space! {peopleWaiting} people in a queue!\n{string.Join(" ",lift)}");
  42.             }
  43.         }
  44.     }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement