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 <iostream>
#include <algorithm>
#include <climits>
#include <array>
#include <map>
#include <set>
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end();
#define pb push_back
#define pp pop_back
#define r0 return 0
using namespace std;
const int N = 2 * 1e6 + 5;
int n,m,l;
int a[N],mn,ans, st;
set <int> s;
bool araferi(int l,int r){
if(s.upper_bound(l) != s.end() && *s.upper_bound(l) < r) return false;
else return true;
}
signed main(){
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a[i];
}
for (int k = 1; k <= n; k++) {
mn = a[k];
ans++;
st = k;
while(a[k] < a[k + 1] && araferi(mn, a[k + 1])){
k++;
}
for (int i = st; i <= k; i++) {
s.insert(a[i]);
}
}
cout << ans;
cout << endl;
r0;
}
# | 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... |