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