-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbio.cpp
58 lines (56 loc) · 923 Bytes
/
bio.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
vector<int> v;
int max=0;
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
for(int k=i;k<=j;k++)
{
v.push_back(a[k]);
}
int c=0,l=0,p=v[0],m=0,q=v.size();
for(int s=0;s<q;s++)
{
if((v[s]<v[s+1])&&(v[0]<v[q-1]))
c++;
else if((v[s]>v[s+1])&&(v[0]>v[q-1]))
l++;
else if((v[s]>v[0])&&(v[s]>v[q-1])&&(v[0]<v[1])&&(v[q-2]>v[q-1]))
{
int ma=q;
if(ma>m)
m=ma;
}
else
m=m;
}
if(c==(v.size()-1))
m=c+1;
else if(l==(v.size()-1))
m=l+1;
else
m=m;
if(m>max)
max=m;
v.clear();
}
}
cout<<max<<endl;
}
return 0;
}