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;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;
#define fur(i, a, b) for(ll i = a; i <= (ll) b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll) b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define nl "\n"
const ll inf = 1e12L;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
pl a[n + 2];
#define x first
#define y second
fur(i, 1, n) {
cin >> a[i].x >> a[i].y;
}
a[0] = a[n + 1] = {0, 0};
sort(a + 1, a + n + 1);
bool under[n + 1] = {};
ll mx = -inf;
ruf(i, n, 1) {
if(a[i].y - a[i].x <= mx) {
under[i] = 1;
} else {
mx = a[i].y - a[i].x;
}
}
mx = -inf;
fur(i, 1, n) {
if(a[i].y + a[i].x <= mx) {
under[i] = 1;
} else {
mx = a[i].y + a[i].x;
}
}
ll ans = n;
fur(i, 1, n) {
if(under[i])
--ans;
}
cout << ans <<nl;
}
# | 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... |