답안 #23671

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
23671 2017-05-18T15:10:46 Z leejseo 사냥꾼 (KOI13_hunter) C++14
100 / 100
83 ms 2292 KB
#include <stdio.h>
#include <algorithm>
#include <time.h>

using namespace std;

struct point{
    int x,y;
    point () {}
    point (int _x, int _y) { x=_x; y=_y; }
    bool operator < (const point& rhs) const {return x < rhs.x; }
};

int m,n,l;
int x[100000];
point animal[100000];
int main()
{
    scanf ("%d%d%d", &m, &n, &l);
    for (int i=0; i<m; i++) scanf ("%d", &(x[i]));
    for (int i=0; i<n; i++) scanf ("%d%d", &(animal[i].x), &(animal[i].y));
    sort (x, x+m);
    sort (animal, animal+n);
    int answer = 0;
    for (int i=0, j=0; i<n; i++)
    {
        while (j<m && x[j]<animal[i].x){
            j++;
        }
        bool flag = false;
        if ((j>0) && (animal[i].x - x[j-1] + animal[i].y <= l)) flag = true;
        if ((j<m) && (x[j]-animal[i].x + animal[i].y <=l)) flag = true;
        if (flag) answer ++;
    }
    printf("%d\n", answer);
    return 0;
}

Compilation message

hunter.cpp: In function 'int main()':
hunter.cpp:19:33: 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:20:50: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=0; i<m; i++) scanf ("%d", &(x[i]));
                                                  ^
hunter.cpp:21:75: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i=0; i<n; i++) scanf ("%d%d", &(animal[i].x), &(animal[i].y));
                                                                           ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2292 KB Output is correct
2 Correct 0 ms 2292 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 2292 KB Output is correct
2 Correct 56 ms 2292 KB Output is correct
3 Correct 53 ms 2292 KB Output is correct
4 Correct 63 ms 2292 KB Output is correct
5 Correct 83 ms 2292 KB Output is correct
6 Correct 53 ms 2292 KB Output is correct
7 Correct 73 ms 2292 KB Output is correct
8 Correct 49 ms 2292 KB Output is correct
9 Correct 66 ms 2292 KB Output is correct
10 Correct 63 ms 2292 KB Output is correct