rt,O(n2)算法都能过。
我的代码:
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
const int kMaxN = 1e5 + 1;
struct E {
int x, y;
} a[kMaxN];
int n, cnt;
bool C(int x) {
for (int i = 1; i <= n; ++i) {
if (i != x && a[x].y <= a[i].y) {
if (a[x].x <= a[i].x && a[x].x - a[x].y >= a[i].x - a[i].y || a[x].x >= a[i].x && a[x].x + a[x].y <= a[i].x + a[i].y) {
return 1;
}
}
}
return 0;
}
int main() {
ios::sync_with_stdio(0);
cout.tie(0), cin.tie(0);
// freopen("mountains.in", "r", stdin);
// freopen("mountains.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i].x >> a[i].y;
}
cnt = n;
for (int i = 1; i <= n; ++i) {
cnt -= C(i);
}
cout << cnt << endl;
return 0;
}