#include <bits/stdc++.h>
#include <cmath>
#include <ios>
#include <iostream>
#include <vector>
#include <random>
#include <set>
#include <map>
#include <random>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define f first
#define s second
const int MOD = 998244353;
const ll inf = 4*1e18;
const int mx = 5*1e5+5;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
vector<P> v;
for (int i = 0; i < n; i++) {
ll a, b; cin >> a >> b;
v.push_back({a, b});
}
sort(v.begin(), v.end());
ll M = 0;
vector<ll> q;
for (int i = 0; i < n; i++) {
ll v1 = v[i].f; ll v2 = v[i].s;
while (!q.empty() && q.back() >= v1-v2) {
q.pop_back();
}
if (v1+v2 >= M) {
M = v1+v2;
q.push_back(v1-v2);
}
}
cout << q.size();
}
| # | 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... |