#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define len(v) (int)((v).size())
template<typename T>
ostream& operator<<(ostream& out, const vector<T> &a){
for (auto& x : a){
out << x << ' ';
}
out << '\n';
return out;
}
template<typename T>
istream& operator>>(istream& in, vector<T> &a){
for (size_t i = 0; i < a.size(); ++i){
in >> a[i];
}
return in;
}
mt19937 gen;
inline void solve() {
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (int i = 0; i < n; ++i){
cin >> a[i].first >> a[i].second;
}
sort(a.begin(), a.end());
stack<pair<int, int>> st;
for (pair<int, int> p : a){
while (!st.empty() && p.first - st.top().first <= p.second - st.top().second){
st.pop();
}
st.push(p);
}
cout << len(st) << '\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout.precision(60);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# | 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... |