#include <bits/stdc++.h>
using namespace std;
#define name "IO"
#define int long long
const int inf = 1e18 + 7;
const int maxn = 1e7 + 5;
int n;
void solve()
{
cin >> n;
vector<pair<int,int>> p;
for(int i = 1; i <= n; i++)
{
int x, y;
cin >> x >> y;
p.push_back({x, y});
}
stack<pair<int,int>> st;
auto check = [&](int x, int y) -> bool{
auto [i, j] = st.top();
if( (x - y) <= (i - j) && (x + y) >= (i + j)) return true;
return false;
};
for(int i = 0; i < p.size(); i++)
{
auto [x, y] = p[i];
bool ok = 1;
while(st.size() && check(x, y))
{
ok = 0;
st.pop();
}
if(st.empty() || ok) st.push({x, y});
}
cout << st.size() << "\n";
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
clock_t start = clock();
int t = 1;
while(t--) solve();
std::cerr << "Time: " << clock() - start << "ms\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... |