#include <bits/stdc++.h>
using namespace std;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a[n],c[n];
for(int &i : a){
cin >> i;
if(i!=-1){
i--;
}
}
for(int &i : c){
cin >> i;
}
set<int>pos;
for(int i = 0;i<n;i++){
pos.insert(i);
}
for(int i : a){
pos.erase(i);
}
set<int>::iterator it = pos.begin();
int currmx = -1;
int ans = 0;
for(int i = 0;i<n;i++){
if(a[i]==-1){
if(it!=pos.end()){
a[i]=*it;
it++;
ans++;
}
}
else if(a[i]>currmx){
ans++;
it=pos.lower_bound(a[i]);
}
currmx = max(currmx,a[i]);
cout << ans << " ";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |