SHARE
TWEET

Untitled

a guest May 19th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. namespace FashionBoutique
  3. {
  4.     using System;
  5.     using System.Linq;
  6.     using System.Collections.Generic;
  7.  
  8.     class Boutique
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             Stack<int> stackOfClothes = new Stack<int>(Console.ReadLine().Split().Select(int.Parse));
  13.  
  14.             int clothesSum = 0; //saveCapacity
  15.             int rackCounter = 1; // racks
  16.  
  17.             int rackCapacity = int.Parse(Console.ReadLine());  //capacity
  18.  
  19.             for (int i = 0; i < stackOfClothes.Count; i++)
  20.             {
  21.                 //int currentNum = clothes.Peek();
  22.                 int currentCloth = stackOfClothes.Peek();
  23.  
  24.  
  25.                 // if (currentNum + saveCapacity <= capacity)
  26.                 if (currentCloth + clothesSum <= rackCapacity)
  27.                 {
  28.                     // saveCapacity += clothes.Pop();
  29.                     clothesSum += stackOfClothes.Pop();
  30.                 }
  31.                 else
  32.                 {
  33.                     // saveCapacity = clothes.Pop();
  34.                     clothesSum = stackOfClothes.Pop();
  35.                     rackCounter++;
  36.                 }
  37.             }
  38.             Console.WriteLine(rackCounter);
  39.         }
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top