이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |