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;
int n;
pair<int,int> a[500005];
bool cmp(pair<int,int>A, pair<int,int>B)
{
if (A.first != B.first)
return A.first < B.first;
return A.second > B.second;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++)
{
int x,e;
cin >> x >> e;
a[i] = {x - e,x + e};
}
sort(a + 1,a + n + 1,cmp);
int ans = 0;
int rmax = 0;
for (int i = 1; i <= n; i++)
{
if (rmax < a[i].second)
rmax = a[i].second,ans++;
}
cout << ans;
return 0;
}
/**
imi imaginez oamenii ca niste intervale
X,E -> [X - E,X + E]
un om a fost deja luat <=> intervalul lui e inclus in al altuia
vreau sa vad efectiv cate intervale nu sunt incluse in alte intervale
**/
# | 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... |