#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define SZ(s) (int)s.size()
#define ff first
#define ss second
const int M = 998244353;
int T, n, m;
set <int> s;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n;
vector <int> a(n);
for(auto &i : a) cin >> i;
s.insert(1e6+1);
int i = 0, ans = 0;
while(i < n){
int x = *s.upper_bound(a[i]), ind = i;
while(a[i] <= x and i < n and a[max(i-1,ind)] <= a[i]){
s.insert(a[i]);
i++;
}
ans++;
}
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... |