#include #include #include #include #include using namespace std; int getcan(vector &a,vector &can,int i){ if(a[i]<=a[i-1]&&a[i]<=a[i+1]) { //cout<<1<<" "; return 1;} if(a[i]>a[i-1]&&a[i]<=a[i+1]){ if(can[i-1]==0) can[i-1]=getcan(a,can,i-1); //cout<<1+can[i-1]<<" "; return 1+can[i-1]; } if(a[i]>a[i+1]&&a[i]<=a[i-1]){ if(can[i+1]==0) can[i+1]=getcan(a,can,i+1); //cout<<1+can[i+1]<<" "; return 1+can[i+1]; } if(a[i]>a[i+1]&&a[i]>a[i-1]){ if(can[i-1]==0) can[i-1]=getcan(a,can,i-1); if(can[i+1]==0) can[i+1]=getcan(a,can,i+1); //cout<<1+(can[i-1]>can[i+1]?can[i-1]:can[i+1])<<" "; return 1+(can[i-1]>can[i+1]?can[i-1]:can[i+1]); } return 0; } int main() { int n; cin>>n; vector a; for(int i=0;i>temp; a.push_back(temp);} vector can(n,0); if(a[0]<=a[1]) can[0]=1; if(a[n-1]<=a[n-2]) can[n-1]=1; if(a[0]>a[1]) can[0]=getcan(a,can,1)+1; if(a[n-1]>a[n-2]) can[n-1]=getcan(a,can,n-2)+1; for(int i=1;i