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<bits/stdc++.h>
using namespace std;
int main(void){
ios::sync_with_stdio(0);cin.tie(0);
int m,n,l;
cin>>m>>n>>l;
vector<int> h(m),x(n),y(n);//hunter, animal
for(int i=0;i<m;i++){
cin>>h[i];
}
for(int i=0;i<n;i++){
cin>>x[i]>>y[i];
}
sort(h.begin(),h.end());
int cnt=0;
for(int i=0;i<n;i++){
if(l<y[i])continue;
int lb=lower_bound(h.begin(),h.end(),x[i])-h.begin();
int ub=lower_bound(h.begin(),h.end(),x[i])-h.begin();
if(lb!=ub){
cnt++;
}
else{
for(int j=ub-3;j<ub+4;j++){
if(j<0||j>=m)continue;
if(abs(x[i]-h[j])+y[i]<=l){
cnt++;
break;
}
}
}
}
cout<<cnt;
}
# | 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... |