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>
using namespace std;
#define MAXN 500001
long long n;
vector<pair<long long,long long>> vec;
long long f[MAXN],maks[MAXN];
bool cmp(pair<long long,long long> a,pair<long long,long long> b)
{
if (a.first<b.first) return true;
else if (b.first<a.first) return false;
else
{
if (a.second>b.second) return true;
else return false;
}
}
int main()
{
cin>>n;
vec.push_back({0,0});
for (long long i=1;i<=n;i++)
{
long long x,e;cin>>x>>e;
vec.push_back({x,e});
}
sort(vec.begin(),vec.end(),cmp);
for (long long i=1;i<=n;i++) f[i]=vec[i].first-vec[i].second;
long long ans=0;maks[1]=f[1];
for (long long i=2;i<=n;i++)
{
if (f[i]>maks[i-1]) {ans++;maks[i]=f[i];}
else maks[i]=maks[i-1];
}
cout<<ans+1<<endl;
}
# | 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... |