Advertisement
korbiniak

Untitled

Oct 22nd, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. static const int N = 5e5 + 10;
  5.  
  6. int nast[N], pop[N];
  7.  
  8. int main() {
  9.     ios_base::sync_with_stdio(false);
  10.     int n;
  11.     cin >> n;
  12.     for (int i = 1 ; i <= n ; ++i) {
  13.         nast[i] = i+1;
  14.         pop[i] = i-1;
  15.     }
  16.  
  17.     for (int i = 0; i < n; ++i) {
  18.         int a;
  19.         cin >> a;
  20.         nast[pop[a]] = nast[a];
  21.         pop[nast[a]] = pop[a];
  22.         if (nast[a] != n+1) {
  23.             cout << nast[a] << "\n";
  24.         } else {
  25.             cout << "NIE\n";
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement