답안 #76057

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

using namespace std;

typedef pair<int, int> pii;

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

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 f = 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;
            f = true;
            break;
        }
    }
    if(!f) {
        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);
    sort(ani, ani+n);
    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 376 KB Output is correct
2 Correct 2 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 508 KB Output is correct
2 Correct 3 ms 508 KB Output is correct
3 Correct 3 ms 508 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 644 KB Output is correct
6 Correct 2 ms 644 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 732 KB Output is correct
2 Correct 2 ms 732 KB Output is correct
3 Correct 2 ms 732 KB Output is correct
4 Correct 2 ms 732 KB Output is correct
5 Correct 2 ms 732 KB Output is correct
6 Correct 2 ms 732 KB Output is correct
7 Correct 2 ms 732 KB Output is correct
8 Correct 2 ms 732 KB Output is correct
9 Correct 2 ms 732 KB Output is correct
10 Correct 2 ms 732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 732 KB Output is correct
2 Correct 3 ms 732 KB Output is correct
3 Correct 4 ms 732 KB Output is correct
4 Incorrect 4 ms 732 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 1416 KB Output is correct
2 Correct 120 ms 1532 KB Output is correct
3 Correct 135 ms 1660 KB Output is correct
4 Correct 126 ms 1660 KB Output is correct
5 Correct 169 ms 1700 KB Output is correct
6 Incorrect 200 ms 1700 KB Output isn't correct
7 Halted 0 ms 0 KB -