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 <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define int long long
#define pb push_back
#define MOD 1000000007
#define NMAX 250001
#define nl '\n'
#define INF 1000000007
#define pii1 pair<int, pair<int,int>> (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int>
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
/*
--------------------DEMONSTRATION---------------------
------------------------END--------------------------
*/
int n;
vector<pii>v;
signed main() {
cin>>n;
v.resize(n+1);
for(int i=1;i<=n;++i)
{
cin>>v[i].first>>v[i].second;
}
auto cmp=[&](pii a,pii b)
{
if(a.first==b.first)
return a.second>b.second;
return a.first>b.first;
};
sort(v.begin()+1,v.end(),cmp);
// for(int i=1;i<=n;++i)
// {
// cout<<v[i].first<<" "<<v[i].second<<nl;
// }
int i=1;
int ans=0;
while(i<=n)
{
int st=i+1;
int dr=n;
int ind=i;
while(st<=dr)
{
int mid=(st+dr)/2;
if(abs(v[i].first-v[mid].first)<=v[i].second-v[mid].second)
{
ind=mid;
st=mid+1;
}
else
dr=mid-1;
}
i=ind+1;
ans++;
}
cout<<ans<<nl;
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... |