This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<algorithm>
using namespace std;
struct pp{
int x,y;
}animal[1000001];
int hunter[1000001];
int ab(int k){
if(k<0) return -k;
return k;
}
int main()
{
int m,n,l,i,j,cnt=0,ans=0;
scanf("%d %d %d",&m,&n,&l);
for(i=1;i<=m;i++)
scanf("%d",&hunter[i]);
for(i=1;i<=n;i++)
scanf("%d %d",&animal[i].x,&animal[i].y);
sort(hunter+1,hunter+m+1);
for(i=1;i<=n;i++){
cnt=0;
j=lower_bound(hunter+1,hunter+m+1,animal[i].x)-hunter;
if(j-1>=1){
if(ab(hunter[j-1]-animal[i].x)+animal[i].y<=l) cnt++;
}
if(j>=1 && j<=m){
if(ab(hunter[j]-animal[i].x)+animal[i].y<=l) cnt++;
}
if(j+1<=m){
if(ab(hunter[j+1]-animal[i].x)+animal[i].y<=l) cnt++;
}
if(cnt) ans++;
}
printf("%d",ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |