Why this solution is not acceptable by SPOJ?

#include
#include
using namespace std;

bool canplacecow(int stall[],int n, int c, int min_space) {
int last_cow = stall[0];
int cnt = 1;

for(int i=1;i<n;i++) {
	if(stall[i]-last_cow>=min_space) {
		last_cow = stall[i];
		cnt++;
		if(cnt==c) {
			return true;
		}
	}
}
return false;

}

int main() {
// your code goes here
int t,n,c,ans=0;
int stall[100000];
cin >> t;
while(t–) {
cin >> n >> c;

	for(int i=0;i<n;i++) {
		cin >> stall[i];
	}
	
	sort(stall,stall+n);
	
	int s=0;
	int e=stall[n-1] -stall[0];
	
	while(s<=e) {
		int mid=(s+e)/2;
		
		bool cowrakhpaye = canplacecow(stall, n,c,mid);
		
		if(cowrakhpaye) {
			ans=mid;
			s=mid+1;
		}
		else {
			e=mid-1;
		}
		
	}
	
	 
}

cout << ans << endl;

return 0;

}

@Sahilgohrisg use long long datatype

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.