Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- int n = 0;
- cin >> n;
- vector<pair<int, bool>> nums(n, pair<int, bool>(0, false));
- int size = 0;
- int ind = -1;
- for (int g = 0; g < 2 * n; g++)
- {
- char x = 0;
- int y = 0;
- cin >> x;
- if (x == '-' && size <= 0)
- {
- cout << "NO";
- return 0;
- }
- else if (x == '+')
- ind++, size++;
- else // -
- {
- size--;
- cin >> y;
- if (ind >= n)
- {
- HER: bool del = false;
- for (int i = 0; i < ind; i++)
- {
- if (!del && !nums[i].second && nums[i].first >= y)
- {
- del = true;
- nums[i].first = y;
- nums[i].second = true;
- }
- else if (del && !nums[i].second)
- nums[i].first = y + 1;
- }
- if (!del)
- {
- cout << "NO";
- return 0;
- }
- }
- else
- {
- if (nums[ind].second)
- goto HER;
- else
- {
- nums[ind].first = y;
- nums[ind].second = true;
- for (int i = 0; i < ind; i++)
- {
- if (!nums[i].second)
- nums[i].first = max(nums[i].first, y + 1);
- }
- }
- }
- }
- }
- cout << "YES" << '\n';
- for (const auto& i : nums)
- cout << i.first << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement