E - 7
思路:
我也讲不清楚,看的大佬的代码,模拟了一下确实非常有道理
code:
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define ld long double
using namespace std;
const int maxn = 1e5 + 9;
const int mod = 1e9 + 7;
ll n, m;
struct Point{
int x, y;
bool operator<(const Point & B)const{
return 1ll * x * B.y > 1ll * y * B.x;
}
};
struct seg{
Point a, b;
bool operator<(const seg &B)const{
return a < B.a;
}
};
void work()
{
cin >> n;
vector <seg> v(n);
for(int i = 0; i < n; ++i){
int x, y;
cin >> x >> y;
Point a = Point{x - 1, y};
Point b = Point{x, y - 1};
v[i] = seg{a, b};
}
sort(v.begin(), v.end());
int ans = 1;
Point last = v[0].a;
for(int i = 1; i < n; ++i){
if(v[i].b < last) continue;
last = v[i].a;
++ans;
}
cout << ans << endl;
}
int main()
{
ios::sync_with_stdio(0);
// int TT;cin>>TT;while(TT--)
work();
return 0;
}