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