Submission #76046

# Submission time Handle Problem Language Result Execution time Memory
76046 2018-09-12T01:24:32 Z chunghan 사냥꾼 (KOI13_hunter) C++14
48 / 100
168 ms 14800 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 = 0, hd = 0;
    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);
    sort(ani, ani+n);
    //cout << x[find(7)] << endl;
    for(int i = 0; i < n; i++) {
        //cout << dist(i, x[find(ani[i].first)]) << ' ' << x[find(ani[i].first)] << ' ' << ani[i].first << ' ' << ani[i].second << endl;
        if(dist(i, x[find(ani[i].first)]) <= l) {
            //cout << ani[i].first << ' ' << ani[i].second << endl;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 448 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 2 ms 700 KB Output is correct
5 Correct 2 ms 700 KB Output is correct
6 Correct 2 ms 700 KB Output is correct
7 Correct 2 ms 700 KB Output is correct
8 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 764 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 3 ms 792 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 2 ms 800 KB Output is correct
8 Correct 2 ms 800 KB Output is correct
9 Correct 2 ms 808 KB Output is correct
10 Correct 2 ms 812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 816 KB Output is correct
2 Correct 3 ms 836 KB Output is correct
3 Correct 4 ms 872 KB Output is correct
4 Incorrect 4 ms 920 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 106 ms 3252 KB Output is correct
2 Correct 120 ms 5176 KB Output is correct
3 Correct 135 ms 7516 KB Output is correct
4 Correct 149 ms 9232 KB Output is correct
5 Correct 162 ms 12268 KB Output is correct
6 Incorrect 168 ms 14800 KB Output isn't correct
7 Halted 0 ms 0 KB -