Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <map>
- #include <queue>
- using namespace std;
- const int maxn = 250;
- int main() {
- ios_base::sync_with_stdio(false);
- int n;
- cin >> n;
- vector<int> v(n);
- for(int i = 0; i < n; i++) {
- cin >> v[i];
- }
- map<int, queue<int> > m;
- vector<int> S;
- int cnt = 0;
- for(int i = 0; i < n; i++) {
- if(!m[v[i]].empty()) {
- S.push_back(m[v[i]].front());
- m[v[i]].pop();
- }
- else {
- int r = 0;
- if(v[i] > 0) {
- r = 1;
- }
- S.push_back(2 * cnt + r);
- m[-v[i]].push(2 * cnt + (1 - r));
- cnt++;
- }
- }
- for(int i = 0; i < S.size(); i++) {
- cout << S[i] << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement