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;
int n;
set<int> sim;
int ans = 1;
int arr[1000005];
int main(){
cin >> n;
for(int i=1;i<n;i++){
cin >> arr[i];
}
int batas = 1000000000;
for(int i=1;i<n;i++){
if(i != 0 && (arr[i] < arr[i-1] || arr[i] > batas)){
ans++;
set<int>::iterator it = sim.upper_bound(arr[i]);
if(it == sim.end()){
batas = 1000000000;
}else{
batas = *it;
}
}
sim.insert(arr[i]);
}
cout << ans << endl;
}
# | 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... |