Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2021
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace FashionBoutique
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[] quantityOfClothes = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.  
  13. int capacityOfRack = int.Parse(Console.ReadLine());
  14.  
  15. Stack<int> clothesStack = new Stack<int>(quantityOfClothes);
  16.  
  17. int countRack = 1;
  18. int sumClothes = 0;
  19.  
  20. //if (clothesStack.Sum() == 0 || capacityOfRack == 0)
  21. //{
  22. // countRack = 0;
  23. // Console.WriteLine(countRack);
  24. // return;
  25. //}
  26.  
  27. while (clothesStack.Count > 0)
  28. {
  29. if (sumClothes < capacityOfRack)
  30. {
  31. sumClothes += clothesStack.Pop();
  32. }
  33. else
  34. {
  35. sumClothes -= capacityOfRack;
  36. countRack++;
  37. }
  38. }
  39.  
  40. if (sumClothes > 0 && countRack > 1)
  41. {
  42. countRack++;
  43. }
  44.  
  45. Console.WriteLine(countRack);
  46. }
  47. }
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement