Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Advanced
- {
- class Program
- {
- static void Main(string[] args)
- {
- int foodQuantity = int.Parse(Console.ReadLine());
- var orders = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- var queueOrders = new Queue<int>(orders);
- Console.WriteLine(orders.Max());
- while (queueOrders.Count > 0)
- {
- var currentOrder = queueOrders.Peek();
- if (currentOrder <= foodQuantity)
- {
- foodQuantity -= currentOrder;
- queueOrders.Dequeue();
- }
- else
- {
- Console.WriteLine($"Orders left: {string.Join(" ", queueOrders)}");
- break;
- }
- }
- if (queueOrders.Count == 0)
- {
- Console.WriteLine("Orders complete");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement