Alex goes shopping question

I m attaching code below can you please tell what’s wrong

#include

using namespace std;
int main() {
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
//Sorting array
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(arr[i]<arr[j])
{
int swap=arr[i];
arr[i]=arr[j];
arr[j]=swap;
}
}
}
/for(int i=0;i<n;i++)
{
cout<<arr[i];
}
/
int q;
cin>>q;
int m[q]={0};
int count =0;
int sum=0;
while(count<q)
{
int money,qty,ans;
cin>>money>>qty;
ans=0;
for(int i=0;i<n;i++)
{
if(arr[i]==money)
{
ans++;
}
sum+=arr[i];
if(i!=0)
{

            if(sum==money)
            {
                ans=ans+i+1;
            }     
        }       
    }
    if(qty==ans)
    {
        m[count]=1;
    }
    else
    {
        m[count]=0;
    }
    sum=ans=0;

    count++;

}
for(int i=0;i<q;i++)
{
    if(m[i]==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

return 0;
}

@asta please share your code using cb.lk/ide
Notice that the question says that Alex wants to spend all the money, ie A amount must be spent using at least k different items.

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.