#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef double ld;
const int INF = 1e10;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<int,int>> arr(n);
for(auto&[a,b]:arr)cin>>a>>b;
stack<pair<int,int>> ans;
auto isSubsetAofB = [&](pair<int,int> a,pair<int,int> b) {
return abs(a.first-b.first)<=b.second-a.second;
};
sort(arr.begin(), arr.end());
for(auto&x:arr) {
while(!ans.empty() and isSubsetAofB(ans.top(),x))ans.pop();
if(!ans.empty() and isSubsetAofB(x,ans.top()))continue;
ans.emplace(x);
}
cout << ans.size() << '\n';
}
# | 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... |