Advertisement
Guest User

Untitled

a guest
Jul 7th, 2021
550
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 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. if (tourists == 0)
  17. {
  18. Console.WriteLine("The lift has empty spots!");
  19. Console.WriteLine(String.Join(" ", lift));
  20. return;
  21. }
  22.  
  23.  
  24. for (int i = 0; i < lift.Length; i++)
  25. {
  26. int maxWagonCapacity = 4 - lift[i];
  27.  
  28. if (maxWagonCapacity > 0 && tourists > 0 && capacity > 0)
  29. {
  30. for (int j = 0; j < maxWagonCapacity; j++)
  31. {
  32. lift[i]++;
  33. tourists--;
  34.  
  35. if (tourists == 0 || tourists == capacity)
  36. {
  37. break;
  38. }
  39. }
  40. }
  41.  
  42. }
  43.  
  44. if (tourists == 0)
  45. {
  46. Console.WriteLine("The lift has empty spots!");
  47. Console.WriteLine(String.Join(" ", lift));
  48. }
  49. else
  50. {
  51. Console.WriteLine($"There isn't enough space! {tourists} people in a queue!");
  52. Console.WriteLine(String.Join(" ", lift));
  53. }
  54. }
  55.  
  56. }
  57.  
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement