Submission #27372

# Submission time Handle Problem Language Result Execution time Memory
27372 2017-07-12T10:50:34 Z jakehsj 사냥꾼 (KOI13_hunter) C++14
100 / 100
86 ms 2292 KB
#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

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 time Memory Grader output
1 Correct 0 ms 2292 KB Output is correct
2 Correct 0 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2292 KB Output is correct
2 Correct 0 ms 2292 KB Output is correct
3 Correct 0 ms 2292 KB Output is correct
4 Correct 0 ms 2292 KB Output is correct
5 Correct 0 ms 2292 KB Output is correct
6 Correct 0 ms 2292 KB Output is correct
7 Correct 0 ms 2292 KB Output is correct
8 Correct 0 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2292 KB Output is correct
2 Correct 0 ms 2292 KB Output is correct
3 Correct 0 ms 2292 KB Output is correct
4 Correct 0 ms 2292 KB Output is correct
5 Correct 0 ms 2292 KB Output is correct
6 Correct 0 ms 2292 KB Output is correct
7 Correct 0 ms 2292 KB Output is correct
8 Correct 0 ms 2292 KB Output is correct
9 Correct 0 ms 2292 KB Output is correct
10 Correct 0 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2292 KB Output is correct
2 Correct 0 ms 2292 KB Output is correct
3 Correct 0 ms 2292 KB Output is correct
4 Correct 0 ms 2292 KB Output is correct
5 Correct 0 ms 2292 KB Output is correct
6 Correct 0 ms 2292 KB Output is correct
7 Correct 0 ms 2292 KB Output is correct
8 Correct 0 ms 2292 KB Output is correct
9 Correct 0 ms 2292 KB Output is correct
10 Correct 0 ms 2292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 2292 KB Output is correct
2 Correct 39 ms 2292 KB Output is correct
3 Correct 63 ms 2292 KB Output is correct
4 Correct 56 ms 2292 KB Output is correct
5 Correct 86 ms 2292 KB Output is correct
6 Correct 76 ms 2292 KB Output is correct
7 Correct 63 ms 2292 KB Output is correct
8 Correct 56 ms 2292 KB Output is correct
9 Correct 73 ms 2292 KB Output is correct
10 Correct 76 ms 2292 KB Output is correct