Advertisement
Guest User

Untitled

a guest
Jul 8th, 2021
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace TheLift
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. int tourists = int.Parse(Console.ReadLine());
  11.  
  12. int[] lift = Console.ReadLine().Split().Select(int.Parse).ToArray();
  13.  
  14. int capacity = (lift.Length * 4) - lift.Sum();
  15.  
  16.  
  17. for (int i = 0; i < lift.Length; i++)
  18. {
  19. int maxWagonCapacity = 4 - lift[i];
  20.  
  21. if (maxWagonCapacity > 0 && tourists > 0 && capacity > 0)
  22. {
  23. for (int j = 0; j < maxWagonCapacity; j++)
  24. {
  25. lift[i]++;
  26. tourists--;
  27. capacity--;
  28.  
  29. if (tourists == 0 || capacity == 0)
  30. {
  31. break;
  32. }
  33. }
  34. }
  35.  
  36. }
  37.  
  38. if (tourists == 0 && capacity > 0)
  39. {
  40. Console.WriteLine("The lift has empty spots!");
  41. Console.WriteLine(String.Join(" ", lift));
  42. }
  43. else if (tourists > 0 && capacity <= 0)
  44. {
  45. Console.WriteLine($"There isn't enough space! {tourists} people in a queue!");
  46. Console.WriteLine(String.Join(" ", lift));
  47. }
  48. else if (tourists <= 0 && capacity == tourists)
  49. {
  50. Console.WriteLine(String.Join(" ", lift));
  51. }
  52. }
  53.  
  54. }
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement