显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
int f=1,num=0;
char c=getchar();
while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
while(c>='0'&&c<='9') num=num*10+c-'0',c=getchar();
return num*f;
}
const int N=200010;
int n,q;
int c[N];
int m;
int v,s;
int l,r,mid;
int query(int x)
{
if(c[1]>=x) return 0;
if(c[n]<x) return n;
l=1,r=n;
while(l<r)
{
mid=(l+r+1)/2;
if(c[mid]>=x) r=mid-1;
else l=mid;
}
return l;
}
int main()
{
freopen("Max.in","r",stdin);
freopen("Max.out","w",stdout);
n=read();q=read();
for(int i=1;i<=n;i++) c[i]=-read();
for(int i=1;i<=n;i++) c[i]+=read();
sort(c+1,c+1+n);
while(q--)
{
v=read();s=read();
if(query(-s)>=v) printf("YES\n");
else printf("NO\n");
}
return 0;
}