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>
typedef long long ll;
#define ii pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
vector<ii> seg;
bool comp(ii a, ii b){
if(a.fi == b.fi) return a.se > b.se;
return a.fi < b.fi;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin >> n;
seg.resize(n);
ll x, y;
for(int i=0; i<n; i++){
cin >> x >> y;
seg[i] = mp(x-y, x+y);
}
sort(seg.begin(), seg.end(), comp);
ll r=0, R=0, cnt = 0;
for(int i=0; i<n; i++){
R = max(r, seg[i].se);
if(seg[i].se > r){
++cnt;
r = R;
}
}
cout << cnt << '\n';
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |