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>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define all(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
const int maxn=500005;
int n;
pii p[maxn];
vector<pii> ans;
bool compare(pii a,pii b){
if(abs(b.first-a.first)<=b.second-a.second) return 1;
return 0;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n;
for(int i=0;i<n;i++){
cin >> p[i].F >> p[i].S;
}
sort(p,p+n);
for(int i=0;i<n;i++){
if(ans.empty()) ans.emplace_back(p[i]);
else{
if(!compare(p[i],ans.back())){
while(!ans.empty() && compare(ans.back(),p[i])) ans.pop_back();
ans.emplace_back(p[i]);
}
}
}
cout << ans.size() << "\n";
}
# | 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... |