Maximum circles

please tell me my mistake
#include <bits/stdc++.h>
using namespace std;

bool compare(pair<int,int> p1,pair<int,int>p2){
return p1.second<p2.second;
}
int main()
{
int n;
cin >> n;
vector<pair<int, int>> v;

while (n--)
{
    int c, r;
    cin >> c >> r;
    int start = c - r;
    int end = c + r;
    v.push_back(make_pair(start,end));
}
sort(v.begin(),v.end(),compare);
int cnt=0;
int current = v[0].second;
for(int i=1;i<n;i++){
    if(v[i].first<=current){
        cnt++;
        current = v[i].second;
    }
}
cout<<cnt<<endl;
return 0;

}

hi @abhinavssr2003_eab0717682969e5c upadted buddy

1 Like

thanks…got the answer

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.