提交时间:2024-03-30 17:38:39
运行 ID: 140730
#include<stdio.h> #include<stdlib.h> #define N 100000 int main(){ int n; int a[N]; int right[N]; int left[N]; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&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]; int r = right[i+1]; if(a[i-1] < a[i+1] && l+r > max) max =l+r; } printf("%d",max+1); }