#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define f first
#define s second
stack<pii> st;
int x,y,n;
int readInt()
{
int x = 0;
char ch = getchar_unlocked();
while (ch < '0' || ch > '9') ch = getchar_unlocked();
while (ch >= '0' && ch <= '9'){
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return x;
}
int main()
{
n = readInt();
for(int i=1;i<=n;i++)
{
x = readInt(),y = readInt();
while(!st.empty()&&x-st.top().f<=y-st.top().s) st.pop();
if(!st.empty()&&x-st.top().f<=st.top().s-y) continue;
st.push({x,y});
}
cout<<st.size();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |