Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <queue>
- using namespace std;
- int main() {
- int quantity, order, maxOrder = 0;
- cin >> quantity;
- cin.ignore();
- string line;
- getline(cin, line);
- queue<int> orders;
- istringstream ss(line);
- while (ss >> order) {
- orders.push(order);
- if (order > maxOrder) {
- maxOrder = order;
- }
- }
- cout << maxOrder << endl;
- while (orders.size()) {
- if (orders.front() <= quantity) {
- quantity -= orders.front();
- orders.pop();
- }
- else {
- break;
- }
- }
- if (orders.size() == 0) {
- cout << "Orders complete\n";
- }
- else {
- cout << "Orders left:";
- while (orders.size()) {
- cout << ' ' << orders.front();
- orders.pop();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement