// Muallif: Mansuraliyev Husanboy Murotali o'g'li >> NamPS
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(a) a.begin(), a.end()
#define F first
#define S second
// 0-9 >> 48-57; A-Z>>65-90 and a-z>>97-122 respectively;
const int N=1e6+5;
void solve(){
int n; cin>>n;
int a[n];
for(int i=0;i<n;i++) cin>>a[i];
set<int> st;
st.insert(a[0]); int ans=1;
int mx=1e9;
ans++;
for(int i=1;i<n;i++){
if(a[i]<a[i-1]||a[i]>mx){
ans++;
auto k=st.lower_bound(a[i]+1);
if(k==st.end()){
mx=1e9;
}else mx=*k;
}
st.insert(a[i]);
}
cout<<ans<<"\n";
}
int main(){
ios;
//int t=1; cin>>t; while(t--)
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |