题意:每个顶点与其左边一个点和下面一个点与原点围成一个四边形,求最小删掉几个四边形,使得所有四边形互不相交。
思路:其实每个顶点可以看作占据了一个斜率区间,那么问题就变成的经典的区间问题,我们直接按照右端点排序然后贪心即可。
/*keep on going and never give up*/
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define lowbit(x) x&(-x)
#define endl '\n'
#define wk is zqx ta die
struct node {
long double l, r;
} q[200005];
bool cmp(node a, node b) {
return a.r < b.r;
}
signed main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
long double x, y;
cin >> x >> y;
q[i].l = (x - 1) / y;
q[i].r = x / (y - 1);
}
sort(q + 1, q + n + 1, cmp);
long double last = -1;
int ans = 0;
for (int i = 1; i <= n; i++) {
if (q[i].l >= last) {
ans++;
last = q[i].r;
}
}
cout << ans << endl;
return 0;
}