Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Fashion_Boutique
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] clothesInBox = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int capacityOfRack = int.Parse(Console.ReadLine());
- var stack = new Stack<int>(clothesInBox);
- int countOfRack = 1;
- int sum = 0;
- while (stack.Count > 0)
- {
- if (sum < capacityOfRack)
- {
- sum += stack.Pop();
- if (sum == capacityOfRack)
- {
- countOfRack++;
- sum = 0;
- }
- else if (sum > capacityOfRack)
- {
- countOfRack++;
- sum = 0;
- }
- }
- }
- Console.WriteLine(countOfRack);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment