In Maximum Circle problem where is wrong with my code can you look it also TLE arises

// Greedy maximum circle problem
#include
#include
#include

using namespace std;

bool compare(pair<int ,int> a, pair<int,int> b){
if(a.second == b.second){
return a.first<b.second;
}
return a.second < b.second;
}

int main() {
int n;
cin>>n;
int c[n];
int r[n];
vector<pair<int,int>> v;
for(int i=0;i<n;i++){
cin>>c[i]>>r[i];
v.push_back(make_pair(c[i]-r[i],c[i] + r[i]));
}

sort(v.begin(),v.end(),compare);
int count = 0;
int cur = v[0].second;
for(int i=1;i<n;i++){
	if(v[i].first > cur){
		cur = v[i].second;
	}else{
		count++;
	}
}
cout<<count;
return 0;

}

hEY @krishav49
Please share your code in Coding Blocks ide

this should be a.first<b.first

This should be count =1

This should be
if(v[i].first>=cur){ cur=v[i].second; count++;}else continue;

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.