This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
int M, N, L;
int H[100005];
pair<int, int> A[100005];
signed main()
{
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> M >> N >> L;
for (int i = 0; i < M; i++) cin >> H[i];
for (int i = 0; i < N; i++) cin >> A[i].x >> A[i].y;
sort(H, H + M); sort(A, A + N);
int ans = 0;
for (int i = 0; i < N; i++)
{
int r = lower_bound(H, H + M, A[i].x) - H;
int l = r - 1;
int ok = 0;
if (0 <= l && l < M)
{
if (abs(A[i].x - H[l]) + A[i].y <= L)
ok = 1;
}
if (0 <= r && r < M)
{
if (abs(A[i].x - H[r]) + A[i].y <= L)
ok = 1;
}
if (ok) ans++;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |