#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
using namespace std;
int n,m,k,i,j,ans,a[200005],p[200005],mx[200005];
signed main(){
cin>>n>>m;
for(k=1; k<=n; k++)cin>>a[k];
p[1]=0; mx[1]=1;
mx[0]=0;
for(k=2; k<=n; k++){
int pos=k-1;
mx[k]=1;
while(pos!=0 && a[k]<=a[pos])pos=p[pos];
p[k]=pos;
mx[k]+=mx[pos];
}
ans=0;
for(k=1; k<=n; k++)ans=max(ans,mx[k]);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |