Maximum circle problem

In this question, I have applied the greedy approach but getting the wrong answer. I have sorted all the pair according to order that the circle whose the second intersection with the x-axis is minimum will come first.

#include<bits/stdc++.h>
using namespace std;

bool cmp(pair<long long int,long long int>c,pair<long long int,long long int>d)
{
return c.second<d.second;
}
int main()
{
long long int n;
cin>>n;
long long int a[n],b[n],i,k,l,s=0;
pair<long long int,long long int>c[n];
for(i=0;i<n;i++)
{
cin>>a[i]>>b[i];
c[i].first=a[i]-b[i];
c[i].second=a[i]+b[i];
}
sort(c,c+n,cmp);

s++;
k=c[0].second;

for(i=1;i<n;i++)
{
    l=c[i].first;
    if(l>=k)
    {

        k=c[i].second;
        s++;
    }
}
cout<<s<<endl;

}

hello @Shivam31,
ur answer should be n-s . becuase in question they are asking u print number of circle we remove so that remaining other circles do not intersect.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.