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, m;
set <int> sor;
int check(int l, int r) {
if(sor.upper_bound(l) == sor.end() || *sor.upper_bound(l)>=r){
return 0;
}
else{
return 1;
}
}
int main(){
cin >> n;
int a[n+10];
for(int i=0; i<n; i++){
cin >> a[i];
}
int ans=0;
for(int i=0; i<n; i++){//segmentis dasawyisi
int st = i;
ans++;
while (i != n - 1 && a[i] <= a[i + 1] && check(a[st], a[i + 1]) == 0) i++;
for(int j=st; j<=i; j++){
sor.insert(a[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... |