Advertisement
Guest User

Untitled

a guest
Jan 17th, 2020
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _05_Fashion_Boutique
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var priceOfClothes = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.  
  13. int capacityOfARack = int.Parse(Console.ReadLine());
  14.  
  15. Stack<int> prices = new Stack<int>(priceOfClothes);
  16.  
  17. int sumOfClothes = 0;
  18. int numOfRacks = 1;
  19.  
  20. //5 4 8 6 3 8 7 7 9 --- orders
  21. //16 -- capacity
  22.  
  23. for (int i = 0; i < priceOfClothes.Length; i++)
  24. {
  25.  
  26.  
  27. sumOfClothes += priceOfClothes[i];
  28.  
  29. if (sumOfClothes == capacityOfARack)
  30. {
  31. numOfRacks++;
  32. sumOfClothes = 0;
  33.  
  34.  
  35.  
  36. if (prices.Any())
  37. {
  38. continue;
  39. }
  40. }
  41.  
  42. else if (sumOfClothes > capacityOfARack)
  43. {
  44.  
  45. numOfRacks++;
  46. sumOfClothes = 0;
  47. i--;
  48.  
  49.  
  50. if (prices.Any())
  51. {
  52. continue;
  53. }
  54. }
  55.  
  56. prices.Pop();
  57.  
  58. }
  59.  
  60. Console.WriteLine(numOfRacks);
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement