This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define isz(x) ((int)x.size())
#define sumof(x) accumulate(all(x), 0ll)
void solve(){
int n; cin >> n;
vector<pair<int, int>> v;
for (int i=1; i<=n; ++i){
int x, e; cin >> x >> e;
v.emplace_back(x-e, e+x);
}
sort(all(v), [&](pair<int, int> x, pair<int, int> y){
return x.first!=y.first?x.first<y.first:x.second>y.second;
});
int last=-1e18, ans=0;
for (auto &i:v){
if (last<i.second){
last=max(last, i.second);
++ans;
}
}
cout << ans;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int ntests=1;
// cin >> ntests;
for (int i=1; i<=ntests; ++i) solve();
return 0;
}
# | 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... |