code is getting executed sucessfully on compilation but run time error while submitting

this code has no problem on compliation
#include

using namespace std;

int main()

{

int t,n,a[n],b[t];



cin>>t;

for(int j=0;j<t;j++)

{

     int count=0;

    cin>>n;

   

      for (int  i = 0; i < n; i++)

      {

       cin>>a[i];

      }

      for (int i = 0; i < n; i++)

      {

        if (a[i]>=1000)

     

       count++;

       

      }

     

      b[j]=count;

}



for (int i = 0; i < t; i++)

{

    cout<<b[i]<<endl;

}



return 0;

}

The runtime error is because of the arrays you have declared. You have used n and t as the array size before taking their values as input. You should first take t as an input and then declare the array b of size t. Same goes for n and array a.
cin>>t;
int b[t];
for(int j=0; j<t; j++)
{
int count = 0;
cin>>n;
int a[n];

This should work fine.

thanks bro