This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e9;
int main(){
int n; cin>>n;
set<int> available;
for(int i = 1; i<=n; i++) available.insert(i);
vector<int> v(n); for(int& i : v) cin>>i;
for(int i : v){
if(available.count(i)) available.erase(i);
}
available.insert(MAXN);
int mx = 0;
int ans = 0;
for(int i = 0; i<n; i++){
if(v[i] == -1){
if(*available.upper_bound(mx) < MAXN){
ans++;
int t = *available.upper_bound(mx);
mx = t;
available.erase(t);
}
}
else{
if(v[i] > mx){
ans++; mx = v[i];
}
}
cout<<ans<<" ";
}
}
# | 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... |