提交时间:2024-04-07 13:14:03
运行 ID: 142333
#include<bits/stdc++.h> using namespace std; #define N 100000 int main(){ int n,a[N],right[N],left[N]; cin>>n; for(int i=0;i<n;i++)cin>>a[i]; left[0]=1; for(int i=1;i<n;i++){ if(a[i]>a[i-1])left[i]=left[i-1]+1; else left[i]=1; } right[n-1]=1; for (int i = n-2; i >=0 ; i--) { if(a[i] < a[i+1])right[i] = right[i+1]+1; else right[i] = 1; } int max=1; for (int i = 1; i <n-1; i++) { int l= left[i-1],r = right[i+1]; if(a[i-1] < a[i+1] && l+r > max)max =l+r; } cout<<max+1; return 0; }