EKO SPOJ codehelp

#include <bits/stdc++.h>
using namespace std;

bool isPossible(vector<int> &v, int N, int M, int mid)
{
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        if (mid > v[i])
        {
            sum += v[i] - mid;
        }
        if (sum >= M)
            return true;
    }
    return false;
}

int cutting(vector<int> &v, int N, int M)
{
    int s = 0;
    int e = v[N - 1];
    int mid = s + (e - s) / 2;
    int ans = -1;
    while (s <= e)
    {
        if (isPossible(v, N, M, mid))
        {
            ans = mid;
            s = mid + 1;
        }
        else
            e = mid - 1;
        mid = s + (e - s) / 2;
    }
    return ans;
}

int main()
{
    int M;
    int N;
    cin >> N >> M;
    vector<int> v;
    for (int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int result = cutting(v, N, M);
    cout << result;
    return 0;
}

This code is not giving me any output.Kindly help to find what is wrong?

One opinion is use the stl function push_back() rather than like an array cause that may be inserting data at positions with no linkage as no length is specified to the vector itself.

My Eko Spoj Solution>>
#include

using namespace std;

bool isPossible(int arr[],int mid,int size,int woodAmnt){

int ans=0;

for(int i=0;i<size;i++){

    if (arr[i]>mid){

        ans=ans+(arr[i]-mid);

    }

}

if (ans>=woodAmnt){

    return true;

}

else{

    return false;

}

}

int findMaxHeight(int arr[],int woodAmount,int size){

int start=0;

int maxi=-1;

for(int i=0;i<size;i++){

    if(arr[i]>maxi){

        maxi=arr[i];

    }

}

//cout<<"Max of the array is>>"<<maxi<<endl;

int end=maxi;

int mid=start+(end-start)/2;

int ans;



while(start<=end){

    if(isPossible(arr,mid,size,woodAmount)){

        ans=mid;

        start=mid+1;

    }

    else{

        end=mid-1;

    }

    mid=start+(end-start)/2;

}

return ans;

}

int main(){

int arr[5]={4, 42, 40, 26, 46};

int M=20;

int ans=findMaxHeight(arr,M,5);

cout<<"The Answer is >>"<<ans;

}