답안 #76050

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
76050 2018-09-12T01:38:43 Z chunghan 사냥꾼 (KOI13_hunter) C++14
48 / 100
162 ms 1804 KB
#include<iostream>
#include<algorithm>
#include<math.h>

using namespace std;

typedef pair<int, int> pii;

int m, n, l, x[100000], cnt;
pii ani[100000];

int dist(int a, int x) {
    return abs(x - ani[a].first) + ani[a].second;
}

int find(int a) {
    int start = 0, end = m-1;
    int mid, rst, ld, hd;
    bool find = false;
    while(start <= end) {
        mid = (start+end)/2;
        if(x[mid] < a) start = mid+1;
        else if(x[mid] > a) end = mid-1;
        else {
            rst = mid;
            find = true;
            break;
        }
    }
    if(!find) {
        ld = abs(a-x[start]);
        hd = abs(a-x[end]);
        rst = ld < hd ? start : end;
    }
    return rst;
}

int main() {
    cin >> m >> n >> l;
    for(int i = 0; i < m; i++)
        cin >> x[i];
    for(int i = 0, a, b; i < n; i++) {
        cin >> a >> b;
        ani[i] = pii(a, b);
    }
    sort(x, x+m);
    for(int i = 0; i < n; i++)
        if(dist(i, x[find(ani[i].first)]) <= l) cnt++;
    cout << cnt;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 448 KB Output is correct
2 Correct 2 ms 496 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 528 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 2 ms 532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 532 KB Output is correct
2 Correct 2 ms 532 KB Output is correct
3 Correct 2 ms 584 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 592 KB Output is correct
6 Correct 2 ms 608 KB Output is correct
7 Correct 2 ms 608 KB Output is correct
8 Correct 2 ms 608 KB Output is correct
9 Correct 2 ms 608 KB Output is correct
10 Correct 2 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 608 KB Output is correct
2 Correct 4 ms 608 KB Output is correct
3 Correct 3 ms 608 KB Output is correct
4 Incorrect 4 ms 608 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 1204 KB Output is correct
2 Correct 121 ms 1424 KB Output is correct
3 Correct 131 ms 1504 KB Output is correct
4 Correct 119 ms 1504 KB Output is correct
5 Correct 162 ms 1660 KB Output is correct
6 Incorrect 157 ms 1804 KB Output isn't correct
7 Halted 0 ms 0 KB -