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