What is the segmentation error in this code?

#include
using namespace std;

int main() {
int t,n,x,mx=-1;
cin>>t;
while(t–)
{
cin>>n>>x;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
if(a[i]<x)
mx=max(i,mx);
}
cout<<mx+1<<endl;
}
// your code goes here
return 0;
}

@2020uec2022,
what’s the question?
u have asked it in priority queue section?

@2020uec2022 is the doubt clear?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.