Submission #27372

#TimeUsernameProblemLanguageResultExecution timeMemory
27372jakehsj사냥꾼 (KOI13_hunter)C++14
100 / 100
86 ms2292 KiB
#include <stdio.h> #include <algorithm> using namespace std; int x[100020]; struct xy{ int dx,dy; }; xy dist[100020]; bool cmp(xy p, xy q) { return p.dx<q.dx; } int abs(int x) { if(x<0) return -x; return x; } int main() { int m,n,l; scanf("%d%d%d",&m,&n,&l); for(int i=0;i<m;i++) scanf("%d",&x[i]); sort(x,x+m); for(int i=0;i<n;i++) scanf("%d%d",&dist[i].dx,&dist[i].dy); sort(dist,dist+n,cmp); int s,e; s=0; int k=0; int ans=0; for(int i=0;i<m;i++) { e=(x[i]+x[i+1])/2; if(i==m-1) e=x[i]+l; while(dist[k].dx>=s&&dist[k].dx<=e&&k<n) { if(abs(dist[k].dx-x[i])+dist[k].dy<=l) ans++; k++; } s=e+1; } printf("%d",ans); }

Compilation message (stderr)

hunter.cpp: In function 'int main()':
hunter.cpp:22:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&m,&n,&l);
                             ^
hunter.cpp:24:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&x[i]);
                          ^
hunter.cpp:27:46: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&dist[i].dx,&dist[i].dy);
                                              ^
#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...