Advertisement
svetlyoek

Untitled

May 16th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Fashion_boutique
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[] clothes = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12. int oneRackCapacity = int.Parse(Console.ReadLine());
  13. int racksCounter = 1;
  14. int sum = 0;
  15. Stack<int> rack = new Stack<int>(clothes);
  16. while(rack.Any())
  17. {
  18. var currentClothes = rack.Peek();
  19. if(sum+currentClothes<=oneRackCapacity)
  20. {
  21. sum += currentClothes;
  22. rack.Pop();
  23. }
  24. else
  25. {
  26. racksCounter++;
  27.  
  28. sum = 0;
  29. }
  30. }
  31. Console.WriteLine(racksCounter);
  32.  
  33. }
  34. }
  35. }
  36. © 2019 GitHub, Inc.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement