Advertisement
spasnikolov131

Untitled

Jan 31st, 2023
18
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Reflection.Metadata.Ecma335;
  4.  
  5. namespace Train
  6. {
  7. internal class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. const int maxPeople = 4;
  12.  
  13. int peopleWaiting = int.Parse(Console.ReadLine());
  14.  
  15. int[] currentState = Console.ReadLine()
  16. .Split(" ")
  17. .Select(int.Parse)
  18. .ToArray();
  19. int vagonaSePylni = 0;
  20. bool isTrue = false;
  21. int peopleOnTheLift = 0;
  22. for (int i = 0; i < currentState.Length; i++)
  23. {
  24. while (currentState[i] < maxPeople && vagonaSePylni < peopleWaiting)
  25. {
  26. currentState[i]++;
  27. vagonaSePylni++;
  28. peopleWaiting--;
  29. isTrue = true;
  30. }
  31.  
  32. }
  33. peopleOnTheLift += vagonaSePylni;
  34. if (isTrue && peopleWaiting == peopleOnTheLift)
  35. {
  36.  
  37. {
  38. Console.WriteLine($"There isn't enough space! {peopleWaiting} people in a queue!{currentState}");
  39. return;
  40. }
  41. }
  42.  
  43.  
  44. foreach (var item in currentState)
  45. {
  46. Console.Write(item + " ");
  47. }
  48. }
  49. }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement