提交时间:2024-04-05 16:49:59
运行 ID: 141518
# include <bits/stdc++.h> using namespace std ; int a [100005] , f [100005] , g [100005] ; int main() { int n , ans = -1 ; cin >> n ; for ( int i = 1 ; i <= n ; i ++ ) { cin >> a [i] ; } f [1] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { f [i] = ( a [i - 1] < a [i] ) ? f [i - 1] + 1 : 1 ; } for ( int i = n ; i >= 1 ; i -- ) { g [i] = ( a [i] < a [i + 1] ) ? g [i + 1] + 1 : 1 ; } for ( int i = 1 ; i <= n ; i ++ ) { ( a [i + 1] >= a [i - 1] + 2 ) ? ans = max ( ans , f [i - 1] + g [i + 1] + 1 ) : 1 ; } cout << ans << endl ; return 0; }