Submission #76058

# Submission time Handle Problem Language Result Execution time Memory
76058 2018-09-12T02:21:24 Z chunghan 사냥꾼 (KOI13_hunter) C++14
100 / 100
182 ms 13056 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;
    if(a <= x[0]) return 0;
    if(a >= x[m-1]) return m-1;
    while(start <= end) {
        mid = (start+end)/2;
        if(x[mid] < a) start = mid+1;
        else if(x[mid] > a) end = mid-1;
        else return mid;
    }
    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;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 448 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
4 Correct 2 ms 568 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Correct 2 ms 588 KB Output is correct
7 Correct 2 ms 588 KB Output is correct
8 Correct 2 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
4 Correct 2 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 3 ms 608 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 2 ms 636 KB Output is correct
9 Correct 2 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 636 KB Output is correct
2 Correct 3 ms 636 KB Output is correct
3 Correct 4 ms 636 KB Output is correct
4 Correct 4 ms 636 KB Output is correct
5 Correct 12 ms 764 KB Output is correct
6 Correct 6 ms 764 KB Output is correct
7 Correct 6 ms 792 KB Output is correct
8 Correct 5 ms 868 KB Output is correct
9 Correct 6 ms 940 KB Output is correct
10 Correct 6 ms 1000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 1848 KB Output is correct
2 Correct 125 ms 1848 KB Output is correct
3 Correct 138 ms 1952 KB Output is correct
4 Correct 121 ms 1952 KB Output is correct
5 Correct 179 ms 2044 KB Output is correct
6 Correct 163 ms 2172 KB Output is correct
7 Correct 182 ms 5104 KB Output is correct
8 Correct 145 ms 7280 KB Output is correct
9 Correct 180 ms 10436 KB Output is correct
10 Correct 171 ms 13056 KB Output is correct