Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- int main() {
- int people;
- cin >> people;
- cin.ignore();
- string wagonLine;
- getline(cin, wagonLine);
- vector<int> wagons;
- for (int i = 0; i < wagonLine.length(); i += 2) {
- wagons.push_back(stoi(&wagonLine[i]));
- }
- for (int i = 0; i < wagons.size(); i++) {
- for (int j = wagons[i]; j < 4; j++) {
- if (people == 0) {
- break;
- }
- wagons[i]++;
- people--;
- }
- }
- if (wagons[wagons.size() - 1] < 4) {
- cout << "The lift has empty spots!\n";
- }
- else if (people > 0) {
- cout << "There isn't enough space! " << people << " people in a queue!\n";
- }
- for (auto& w : wagons) {
- cout << w << ' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement