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 fi first
#define se second
int main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n; cin >> n;
// x, y
pair<int, int> p[n + 1];
for(int i = 1; i <= n; i++)
cin >> p[i].fi >> p[i].se;
int suf[n + 2] = {};
int prf[n + 2] = {};
prf[0] = INT_MIN;
prf[n + 1] = INT_MIN;
suf[0] = INT_MAX;
suf[n + 1] = INT_MAX;
for(int i = 1; i <= n; i++)
prf[i] = max(prf[i - 1], p[i].fi + p[i].se);
for(int i = n; i >= 1; i--)
suf[i] = min(suf[i + 1], p[i].fi - p[i].se);
int ans = n;
for(int i = 1; i <= n; i++)
ans -= ((p[i].fi + p[i].se <= prf[i - 1]) || (p[i].fi - p[i].se >= suf[i + 1]));
cout << ans << endl;
}
# | 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... |