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>
#include <iomanip>
#define ll long long
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define str string
#define pii pair<int,int>
#define sz(x) x.size()
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define mii map<int,int>
#define mll map<ll,ll>
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yess cout<<"Yes\n";
#define noo cout<<"No\n";
using namespace std;
#define maxn 2000101
#define mod 1000000007
void solve(){
int n;
cin>>n;
vector<pair<int,int>> v;
for(int i=1;i<=n;i++){
int q,w;
cin>>q>>w;
if(v.size()==0){
v.pb(mp(q,w));
continue;
}
else{
pair<int,int>p=v.back();
if(abs(p.ff-q)<=p.ss-w){
continue;
}
while(v.size()){
pair<int,int>p=v.back();
if(abs(p.ff-q)<=w-p.ss){
v.pop_back();
}
else{
break;
}
}
v.pb(mp(q,w));
}
}
cout<<v.size();
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//srand( time(0));
//freopen("sum.in", "r", stdin);
//freopen("sum.out", "w", stdout);
int tests=1;
//cin>>tests;
for(int i=1;i<=tests;i++){
//cout<<"Case "<<i<<": \n";
solve();
}
}
# | 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... |