Advertisement
dMundov

04._Fast_Food

May 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5.  
  6. namespace _04._Fast_Food
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12. #if DEBUG
  13.             Console.SetIn(new StreamReader(@"C:\Users\dMundov\Desktop\input.txt"));
  14. #endif
  15.             int foodQuantity = int.Parse(Console.ReadLine());
  16.  
  17.             int[] inputOrders = Console.ReadLine()
  18.                 .Split(" ").Select(int.Parse).ToArray();
  19.  
  20.             Queue<int> orders = new Queue<int>(inputOrders);
  21.  
  22.             Console.WriteLine(orders.Max());
  23.  
  24.             while (orders.Count > 0)
  25.             {
  26.                 int currentOtder = orders.Peek();
  27.                 if (foodQuantity - currentOtder >= 0)
  28.                 {
  29.                     foodQuantity -= currentOtder;
  30.                     orders.Dequeue();
  31.                 }
  32.                 else
  33.                 {
  34.                     Console.WriteLine($"Orders left: {string.Join(" ", orders)}");
  35.                     break;
  36.                 }
  37.             }
  38.             if (orders.Count == 0)
  39.             {
  40.                 Console.WriteLine("Orders complete");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement