#include <bits/stdc++.h>
//qwerty47924692
using namespace std;
#define f first
#define s second
using ll = long long;
const ll N=2e5+29;
const string br="617283";
ll n,a[N],ans=1,k;
vector<ll>b[N];
set<ll>s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for(ll i=1;i<=n;i++){
cin>>a[i];
}
s.insert(a[1]);
for(ll i=2;i<=n;i++){
if(a[i]==a[i-1]){
continue;
}
auto j=s.lower_bound(a[i]);
if(j==s.begin()){
ans++;
s.insert(a[i]);
continue;
}
j--;
if(*j!=a[i-1]){
ans++;
}
s.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... |