Advertisement
svetlyoek

Untitled

May 17th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Fast_food
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int foodQuantity = int.Parse(Console.ReadLine());
  12. int[] orders = Console.ReadLine().Split().Select(int.Parse).ToArray();
  13.  
  14. Queue<int> queue = new Queue<int>(orders);
  15. Console.WriteLine($"{queue.Max()}");
  16. while (queue.Count > 0)
  17. {
  18. var currentOrder = queue.Peek();
  19. if (foodQuantity - currentOrder >= 0)
  20. {
  21.  
  22. foodQuantity -= currentOrder;
  23. queue.Dequeue();
  24. }
  25. else
  26. {
  27. Console.Write($"Orders left: {string.Join(" ", queue)}");
  28. return;
  29. }
  30.  
  31. }
  32.  
  33. Console.WriteLine($"Orders complete");
  34.  
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement