#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
int a[110], f[110],dp[110];
int main()
{
int t;
cin >> t;
while(t--)
{
cin >> n;
int ans = 1;
for(int i = 0; i < n; i++)
{
cin >> a[i];
f[i] = 1;
dp[i] = 1;
for(int j = i; j >= 0; j--)
{
if(a[i] < a[j]) dp[i] = max(dp[i], dp[j]+1);
if(a[i] > a[j]) f[i] = max(f[i], f[j]+1);
}
}
for(int i = 0; i < n; i++) ans = max({ans,dp[i],f[i]});
cout << ans << endl;
}
return 0;
}
05-07
289
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-12
1632
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-12
390
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-03
688
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-29
7810
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)