hakimlonglopb
Rating
-
Bài tập
1
Điểm
27
Rating #
-
Điểm #
27851
Giới thiệu
include <bits/stdc++.h>
typedef long long ll;
define pll pair<ll,ll>
using namespace std;
ll kt(vector<ll> v)
{
for (ll i=1;i<v.size();i++)
if((v[i]\<v[i+1]&&v[i]>v[i-1])||(v[i]>v[i+1]&&v[i]<v[i+1]))return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
ll n;
cin>>n;
ll a[n];
vector<ll> v;
for (ll i=0;i<n;i++){
cin>>a[i];
}
ll dem=0;
ll dem2=0;
for (ll i=0;i<n;i++)
{
v.push_back(a[i]);
for (ll j=i+1;j<n;j++)
v.push_back(v[j]);
if(kt(v)==0)
{
dem=v.size();
dem2=max(dem,dem2);
}
else {v.clear();
break;}
}
cout<<dem2-1;
return 0;
}