Binary searching the turning point of a function
Don't use using namespace std; Writing std:: a few times isn't that bad, and it helps keep the std lib types identifiable in your code.



Don't use globals so much. It is much better to limit the scope of variables to where they are needed and pass them around (possibly by reference) when needed. Usernumber for example is only used when filling the array, So something like this is much better:

for (int u = 0; u &lt; arraysize; u++) {
    long long number;
    std::cin &gt;&gt; number;
    userArray.push_back(number);
}




vectorsum has a vector passed by value, this will copy the entire vector. instead you'll want to pass by const ref:

int vectorsum(const std::vector&lt;long long&gt;&amp; userVector) {
    int ans = std::accumulate(userVector.begin(), userVector.end(), 0);
    return ans;
}


You don't really need this function at all though, you can keep a running total instead and save yourself the loop.



You keep rebuilding the vectors over and over again, you don't even need to do that. Instead you only need to keep track of the sum of the current subarray you are testing and how many subarrays you have built already. 

You can also keep track of the largest subarray sum and pass it back as new upperbound. This will reduce the iteration time once the options have been narrowed down somewhat because then you will never try 2 numbers that will create the same partition.

long long isPossible(const std::vector&lt;long long&gt; &amp;user_array, long long max_sum, int max_number_subarrays) {

    long long running_sum = 0;
    long long largest_sum = 0;
    int subarray_count = 0;
    for (auto current : userArray) {
        if (running_sum + current &lt;= max_sum) {
            running_sum += current;
        } else {
            if(running_sum &gt; largest_sum) 
                 largest_sum = running_sum;

            running_sum = current;

            subarray_count++;
            if(subarray_count &gt; max_number_subarrays) 
                return -1; //early out

        }
    }

    return largest_sum;
}


and in the while loop.

while (left + 1 != right) { //Binary search
    middle = ceil((left + right) / 2);
    long long result = isPossible(userArray, middle, numberofsubarrays)
    if (result &gt;= 0) {
        right = result;
    }
    else {
        left = middle;
    }
}
std::cout &lt;&lt; right &lt;&lt; endl;




You can initialize left with the largest number in the input Because if it was less than at least one sub array sum will be larger than it. 

right can be initialized with the sum of the array where every element is in a single subarray.

int left = 0;
int right = 0;

for (int u = 0; u &lt; arraysize; u++) {
    long long number;
    std::cin &gt;&gt; number;
    userArray.push_back(number);

    if(left &lt; number) 
        left = number;
    right+= number;
}