Submission #6925

# Submission time Handle Problem Language Result Execution time Memory
6925 2014-07-10T14:23:27 Z ansol1111 사냥꾼 (KOI13_hunter) C++
100 / 100
76 ms 2264 KB
#include<stdio.h>
#include<algorithm>

int m, n, l, a[100005], hunter;

struct A
{
    int x, y;
};

A b[100005];

int cmp(const A &a, const A &b)
{
    return a.x<b.x || (a.x==b.x && a.y<b.y);
}

int input()
{

    int i;

    scanf("%d %d %d",&m,&n,&l);
    for(i=1 ; i<=m ; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1 ; i<=n ; i++)
    {
        scanf("%d %d",&b[i].x,&b[i].y);
    }
    std::sort(a+1,a+1+m);
    std::sort(b+1,b+1+n,cmp);

    return 0;
}

int process()
{
    int i, j=1, num, k=0;

    for(i=1 ; i<=n ; i++)
    {
        k=0;
        if(a[1]>=b[i].x)
        {
            k=1;
            num=a[1]-b[i].x;
            if(num<0) num*=(-1);
            num+=b[i].y;
            if(num<=l) hunter++;
        }
        else if(a[m]<b[i].x && k==0)
        {
            k=1;
            num=a[m]-b[i].x;
            if(num<0) num*=(-1);
            num+=b[i].y;
            if(num<=l) hunter++;
        }
        else if(k==0)
        {
            if(b[i].x>=a[j] && b[i].x<=a[j+1])
            {
                num=a[j]-b[i].x;
                if(num<0) num*=(-1);
                num+=b[i].y;
                if(num<=l) hunter++;
                else
                {
                    num=a[j+1]-b[i].x;
                    if(num<0) num*=(-1);
                    num+=b[i].y;
                    if(num<=l) hunter++;
                }
            }
            else
            {
                i--;
                if(j+1<=m)
                {
                    j++;
                }
            }
        }
    }

    return 0;
}

int output()
{

    printf("%d\n",hunter);

    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 Correct 0 ms 2264 KB Output is correct
3 Correct 0 ms 2264 KB Output is correct
4 Correct 0 ms 2264 KB Output is correct
5 Correct 0 ms 2264 KB Output is correct
6 Correct 0 ms 2264 KB Output is correct
7 Correct 0 ms 2264 KB Output is correct
8 Correct 0 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2264 KB Output is correct
2 Correct 0 ms 2264 KB Output is correct
3 Correct 0 ms 2264 KB Output is correct
4 Correct 0 ms 2264 KB Output is correct
5 Correct 0 ms 2264 KB Output is correct
6 Correct 0 ms 2264 KB Output is correct
7 Correct 0 ms 2264 KB Output is correct
8 Correct 0 ms 2264 KB Output is correct
9 Correct 0 ms 2264 KB Output is correct
10 Correct 0 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2264 KB Output is correct
2 Correct 0 ms 2264 KB Output is correct
3 Correct 0 ms 2264 KB Output is correct
4 Correct 0 ms 2264 KB Output is correct
5 Correct 0 ms 2264 KB Output is correct
6 Correct 0 ms 2264 KB Output is correct
7 Correct 0 ms 2264 KB Output is correct
8 Correct 0 ms 2264 KB Output is correct
9 Correct 0 ms 2264 KB Output is correct
10 Correct 0 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2264 KB Output is correct
2 Correct 48 ms 2264 KB Output is correct
3 Correct 60 ms 2264 KB Output is correct
4 Correct 52 ms 2264 KB Output is correct
5 Correct 64 ms 2264 KB Output is correct
6 Correct 76 ms 2264 KB Output is correct
7 Correct 72 ms 2264 KB Output is correct
8 Correct 60 ms 2264 KB Output is correct
9 Correct 76 ms 2264 KB Output is correct
10 Correct 68 ms 2264 KB Output is correct