#include #include using namespace std; int n; vector a; vector> dp; int nya(int i, int j) { if(dp[i][j] != -1) { return dp[i][j]; } int res = 2; int x = a[j] - a[i]; for(int k=j+1; k 0 && y > 0 && x < y) || (x < 0 && y < 0 && x < y) || (x > 0 && y < 0)) { res = max(res, nya(j, k) + 1); } } return dp[i][j] = res; } int main(void) { int t; scanf("%d", &t); for(int cases=0; cases(n, -1)); int res = 1; for(int i=0; i