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>
int m, n, l, a[100005], hunter;
struct A
{
int x, y;
};
A b[100005];
int cmp(const A &a, const A &b)
{
return a.x<b.x || (a.x==b.x && a.y<b.y);
}
int input()
{
int i;
scanf("%d %d %d",&m,&n,&l);
for(i=1 ; i<=m ; i++)
{
scanf("%d",&a[i]);
}
for(i=1 ; i<=n ; i++)
{
scanf("%d %d",&b[i].x,&b[i].y);
}
std::sort(a+1,a+1+m);
std::sort(b+1,b+1+n,cmp);
return 0;
}
int process()
{
int i, j=1, num, k=0;
for(i=1 ; i<=n ; i++)
{
k=0;
if(a[1]>=b[i].x)
{
k=1;
num=a[1]-b[i].x;
if(num<0) num*=(-1);
num+=b[i].y;
if(num<=l) hunter++;
}
else if(a[m]<b[i].x && k==0)
{
k=1;
num=a[m]-b[i].x;
if(num<0) num*=(-1);
num+=b[i].y;
if(num<=l) hunter++;
}
else if(k==0)
{
if(b[i].x>=a[j] && b[i].x<=a[j+1])
{
num=a[j]-b[i].x;
if(num<0) num*=(-1);
num+=b[i].y;
if(num<=l) hunter++;
else
{
num=a[j+1]-b[i].x;
if(num<0) num*=(-1);
num+=b[i].y;
if(num<=l) hunter++;
}
}
else
{
i--;
if(j+1<=m)
{
j++;
}
}
}
}
return 0;
}
int output()
{
printf("%d\n",hunter);
return 0;
}
int main()
{
input();
process();
output();
return 0;
}
# | 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... |