One test case not getting passed

in the given input test case- first i sorted the array in ascending order else it was giving the answer as ’ 1 '.

my code;-
#include
#include
using namespace std;
void bubble_sort(int stalls,int n){
for(int i=0;i<=n-1;i++){
for(int j=0;j<=n-i-1;j++){
if(
(stalls+j)>(stalls+j+1)){
swap(
(stalls+j) , *(stalls+j+1));
}
}
}
}

bool cankeepcows(int n,int stalls[],int c,int min_sep){
int last_cow=stalls[0];
int cnt=1;
//first cow is to be placed in first stall
for(int i=0;i<n;i++){
if(stalls[i]-last_cow>=min_sep){
last_cow=stalls[i];
cnt++;
if(cnt==c){
return true;
}
}
}
return false;
}
int main(){
int n; //no of stalls
cin>>n;
int c; //no of cows
cin>>c;
int stalls[100000];
for(int i=0;i<n;i++){
cin>>stalls[i];
}
bubble_sort(stalls,n);

int s=0;
int e=stalls[n-1] - stalls[0];
int ans=0;

while(s<=e){
    int mid=(s+e)/2;
 
    bool cowrakhpaye=cankeepcows(n,stalls,c,mid);
    if(cowrakhpaye){
        ans=mid;
        s=mid+1;
    }
    else{
        e=mid-1;
    }
}
cout<<ans<<endl;
return 0;

}

hi @anshita_1312 instead of bubble sort use faster sorts method eg sort(stalls,stalls+n); use this