Advertisement
Spocoman

04. Fast Food

Jan 11th, 2024
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <queue>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     int quantity, order, maxOrder = 0;
  10.     cin >> quantity;
  11.     cin.ignore();
  12.  
  13.     string line;
  14.     getline(cin, line);
  15.  
  16.     queue<int> orders;
  17.  
  18.     istringstream ss(line);
  19.  
  20.     while (ss >> order) {
  21.         orders.push(order);
  22.         if (order > maxOrder) {
  23.             maxOrder = order;
  24.         }
  25.     }
  26.  
  27.     cout << maxOrder << endl;
  28.  
  29.     while (orders.size()) {
  30.         if (orders.front() <= quantity) {
  31.             quantity -= orders.front();
  32.             orders.pop();
  33.         }
  34.         else {
  35.             break;
  36.         }
  37.     }
  38.  
  39.     if (orders.size() == 0) {
  40.         cout << "Orders complete\n";
  41.     }
  42.     else {
  43.         cout << "Orders left:";
  44.         while (orders.size()) {
  45.             cout << ' ' << orders.front();
  46.             orders.pop();
  47.         }
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement