Code problem, compilation gives correct result but submission shows error

this is solution of alex shopping problem. when i am compiling and running then i am getting the correct answer but while submitting it shows error. please tell what is the issue.
#include
using namespace std;
int main() {
int n;
cin>>n;
int *arr=new int[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int q;
int *a=new int[q];
int *b=new int[q];
int *c=new int[q];
cin>>q;
for(int i=0;i<q;i++)
{ int sum=0;
cin>>a[i];
cin>>b[i];
for(int j=0;j<n;j++)
{
if(a[i]%arr[j]==0)
{sum++;}
}
if(sum>=b[i])
{c[i]=1;}
else
{c[i]=0;}
}
for(int k=0;k<q;k++)
{
if(c[k]==1)
{cout<<“Yes”<<endl;}
else
{cout<<“No”<<endl;}
}
return 0;
}

hi @akshatg2004_c1794fd8daa25ae6 take input of q before declaring arrays

thanks bhaiya, I got it.

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.