Advertisement
Guest User

Untitled

a guest
Oct 19th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5.  
  6. namespace FastFood
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int foodQuantity = int.Parse(Console.ReadLine());
  13. Queue<int> food = new Queue<int>();
  14. int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  15. int biggestOrder = 0;
  16. List<int> ordersLeft = new List<int>();
  17. bool enough = false;
  18.  
  19.  
  20. for (int i = 0; i < input.Length; i++)
  21. {
  22. food.Enqueue(input[i]);
  23.  
  24. }
  25.  
  26. while (food.Count >= 1)
  27. {
  28. if (food.Peek() < foodQuantity)
  29. {
  30. if (food.Peek() > biggestOrder)
  31. {
  32. biggestOrder = food.Peek();
  33. }
  34.  
  35. enough = true;
  36.  
  37. }
  38.  
  39. else
  40. {
  41. ordersLeft.Add(food.Peek());
  42. enough = false;
  43. }
  44. foodQuantity -= food.Dequeue();
  45. }
  46. if (enough)
  47. {
  48. Console.WriteLine(biggestOrder);
  49. Console.WriteLine("Orders complete");
  50.  
  51. }
  52. else
  53. {
  54. Console.WriteLine(biggestOrder);
  55. Console.Write("Orders left: ");
  56. foreach (var left in ordersLeft)
  57. {
  58. Console.Write(left + " ");
  59. }
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement