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 <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int lld;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)
lld absol(lld x){return max(x,-x);}
bool dom(pair<lld,lld> a, pair<lld,lld> b){
if(absol(a.first-b.first)<=a.second-b.second)return true;
return false;
}
void solve(){
int n;
cin>>n;
vector<pair<lld,lld> >V(n);
rep(i,0,n)cin>>V[i].first>>V[i].second;
sort(V.begin(),V.end());
vector<pair<lld,lld> >ans;
trav(a,V){
if(ans.size()==0){
ans.push_back(a);
}else{
if(!dom(ans[ans.size()-1],a)){
while(ans.size()>0 && dom(a,ans[ans.size()-1]))ans.pop_back();
ans.push_back(a);
}
}
}
cout<<ans.size()<<"\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int tt=1;
//cin>>tt;
while(tt--){
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... |