Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace FashionBoutique
- {
- using System;
- using System.Linq;
- using System.Collections.Generic;
- class Boutique
- {
- static void Main(string[] args)
- {
- Stack<int> stackOfClothes = new Stack<int>(Console.ReadLine().Split().Select(int.Parse));
- int clothesSum = 0; //saveCapacity
- int rackCounter = 1; // racks
- int rackCapacity = int.Parse(Console.ReadLine()); //capacity
- for (int i = 0; i < stackOfClothes.Count; i++)
- {
- //int currentNum = clothes.Peek();
- int currentCloth = stackOfClothes.Peek();
- // if (currentNum + saveCapacity <= capacity)
- if (currentCloth + clothesSum <= rackCapacity)
- {
- // saveCapacity += clothes.Pop();
- clothesSum += stackOfClothes.Pop();
- }
- else
- {
- // saveCapacity = clothes.Pop();
- clothesSum = stackOfClothes.Pop();
- rackCounter++;
- }
- }
- Console.WriteLine(rackCounter);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement