Submission #4949

#TimeUsernameProblemLanguageResultExecution timeMemory
4949hana5505사냥꾼 (KOI13_hunter)C++98
100 / 100
76 ms12804 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...