Submission #4489

# Submission time Handle Problem Language Result Execution time Memory
4489 2013-10-11T08:43:21 Z ansol4328 사냥꾼 (KOI13_hunter) C++
10 / 100
36 ms 2264 KB
#include<stdio.h>
#include<algorithm>
#include<math.h>

struct A
{
    int x, y;
};
A animal[100002];

int m, n, l;
int h[100002], get;

struct SORTF
{
    bool inline operator () (A a, A b)
    {
        return a.x < b.x;
    }
};

struct sortf
{
    bool inline operator () (A a, A b)
    {
        return a.y < b.y;
    }
};

int input()
{
    int i, k, c;
    scanf("%d %d %d",&m,&n,&l);
    for(i=1 ; i<=m ; i++)
    {
        scanf("%d",&h[i]);
    }
    for(i=1 ; i<=n ; i++)
    {
        scanf("%d %d",&animal[i].x,&animal[i].y);
    }
    std::sort(h+1,h+m+1);
    std::sort(animal+1,animal+1+n,SORTF());
    k=0;
    for(i=2 ; i<=n ; i++)
    {
        if(animal[i].x==animal[i-1].x && k==0)
        {
            k=i-1;
        }
        c=i-1;
        if(animal[i].x!=animal[i-1].x)
        {
            std::sort(animal+k,animal+1+c,sortf());
            k=i;
        }
    }
    return 0;
}

int process()
{
    int d1, d2, cnt=1, i, c, comp, k;
    for(i=1 ; i<=n ; i++)
    {
        d1=abs(h[cnt]-animal[i].x);
        d2=animal[i].y;
        c=cnt;
        while(l<d1)
        {
            cnt++;
            d1=abs(h[cnt]-animal[i].x)+animal[i].y;
        }
        if(l>=d1+d2 || l>=abs(h[cnt+1]-animal[i].x)+animal[i].y) get++;
    }
    return 0;
}

int output()
{
    printf("%d",get);
    return 0;
}

int main()
{
    input();
    process();
    output();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2264 KB Output is correct
2 Correct 0 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2264 KB Output is correct
2 Incorrect 0 ms 2264 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2260 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2260 KB SIGSEGV Segmentation fault
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 36 ms 2264 KB Output isn't correct
2 Halted 0 ms 0 KB -