the code is working in hackerblocks but not when submitted in course dashboard
#include
using namespace std;
int main() {
int t;
cin>>t;
for(int j=0;j<t;j++){
int n;
cin>>n;
int a[n],inc[n],dec[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
for (int i = 0; i < n ; i++){
dec[i] = 1;
}
for (int i = 0; i < n ; i++){
inc[i] = 1;
}
for(int i=1;i<n;i++){
for(int j=0;j<i;j++){
if(a[i]>a[j] && inc[i]<inc[j]+1){
inc[i]=inc[j]+1;
}
}
}
for(int i=n-2;i>=0;i--){
for(int j=n-1;j>i;j--){
if(a[i]>a[j] && dec[i]<dec[j]+1){
dec[i]=dec[j]+1;
}
}
}
int max;
max=(inc[0]+dec[0]-1);
for(int i=1;i<n;i++){
if(max<(inc[i]+dec[i]-1)){
max=inc[i]+dec[i]-1;
}
}
cout<<max<<endl;
}
return 0;
}