Doof on Cartesian

https://www.codechef.com/problems/CLPNT
I solved this problem using a simple approach please tell me where I am wrong.

#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
int main() {
LL t;
cin>>t;
while(t–)
{
LL w;
cin>>w;
LL walls[w];
for(LL i=0;i<w;i++)
{
cin>>walls[i];
}
sort(walls,walls+w);
LL q;
cin>>q;
LL x[q],y[q];
for(LL i=0;i<q;i++)
{
cin>>x[i]>>y[i];
}
for(LL i=0;i<q;i++)
{
LL count=0;
for(LL j=0;j<w;j++)
{
if(x[i]+y[i]>walls[j])
{
count++;
}

             if(x[i]+y[i]==0)
	            {
	            count=0;
	            }
            if(x[i]+y[i]==walls[w-1]&&(x[i]!=0||y[i]!=0))
            {
                count=-1;
                break;
            }
            if(x[i]+y[i]<walls[j])
            {
                break;
            }
            
        }
        cout<<count<<endl;
    }
}
return 0;

}

Try defining a map to store the “alive” walls. An “alive” wall is defined as a wall present in the current plane… Try not manually searching in O(n) time and use STL. And don’t use an array, try using a vector if you’re using C++11 (vector<ll> a(n) where ll is defined as long long int).