Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace CupsAndBottles
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] cupsCapacity = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- int[] bottlesWithWater = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- var stackOfBottles = new Stack<int>(bottlesWithWater);
- var queueOfCups = new Queue<int>(cupsCapacity);
- int totalWastedWater = 0;
- while (true)
- {
- if (stackOfBottles.Peek() >= queueOfCups.Peek())
- {
- int currentBottle = stackOfBottles.Pop();
- int currentCup = queueOfCups.Dequeue();
- int wastedWater = currentBottle - currentCup;
- totalWastedWater += wastedWater;
- stackOfBottles.Pop();
- queueOfCups.Dequeue();
- }
- else
- {
- //??? TO DO
- }
- if (stackOfBottles.Count == 0)
- {
- Console.WriteLine("Cups: " + string.Join(" ", queueOfCups));
- break;
- }
- if (queueOfCups.Count == 0)
- {
- Console.WriteLine("Bottles: " + string.Join(" ", stackOfBottles));
- break;
- }
- }
- Console.WriteLine($"Wasted litters of water: {totalWastedWater}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement