Aggressive cows

wrong output
#include

using namespace std;
bool canPlaceCows(long long int stalls[],int n, int c, int min_seperation ){
long long int lastCow = stalls[0];
int count = 1;
for(int i=1;i<n;i++){
if(stalls[i]-lastCow>=min_seperation)
{
lastCow = stalls[i];
count++;
if(count == c){
return true;
}

    }
}
return false;

}
int main(){
int n, c;
cin>>n>>c;
long long int stalls[100005];
for(int i=0;i<n;i++){
cin>>stalls[i];
}
long long int s=0;
long long int e= stalls[n-1]-stalls[0];
long long int ans = 0;
while(s<=e)
{
int m=(s+e)/2;
bool cowsRakhPaye = canPlaceCows(stalls,n,c,m);
if(cowsRakhPaye)
{

                ans = m;
                s=m+1;

        }
        else
            {
                e=m-1;
            }


    }
    cout<<ans<<endl;

return 0;}

I have edited your code… Try to submit it now…

what is the mistake in the code that i wrote?

I have replaced long long int ans = 0; to long long int ans = -1
and also this thing as,
if(cowsRakhPaye==true)
{
if(m>ans)
{
ans = m;
}
s=m+1;
}