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