#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> su(n),di(n);
stack<int> st;
for(int i = 0;i < n;i++){
int x,y;
cin >> x >> y;
su[i] = x + y;
di[i] = x - y;
bool f = false;
while((int) st.size() && di[i] <= di[st.top()]){
st.pop();
f = true;
}
if((int)st.size() == 0){
st.push(i);
}else if(f){
st.push(i);
}else{
if(su[st.top()] < su[i]){
st.push(i);
}
}
}
cout << (int) st.size() << '\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... |