No test case passed

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

bool check(vectorv,int n,int m,int mid){
int curr = v[0];
int count = 1;
for(int i=0;i<n;i++){
if(curr+v[i]>mid){
count++;

  }
  curr = v[i];
  if(count>m){
	  return false;
  }

}

return true;

}

int ans(vectorv,int n,int m){
int start = v[n-1];
int sum = 0;
int ans = -1;
for(int i=0;i<n;i++){
sum = sum + v[i];
}

int end = sum;
while(start<=end){
int mid = (start+end)/2;
bool check1 = check(v,n,m,mid);
if(check1==true){
ans = mid;
end = mid - 1;

}else{
start = mid + 1;
}

}

return ans;

}

int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int m;
cin>>m;
vectorv;
for(int i=0;i<n;i++){
int x;
cin>>x;
v.push_back(x);
}

	cout << ans(v,n,m);

}

}

is this the code of winning CB scholarship? since you raised this doubt under winning CB scholarship problem. but your solution seems to be of different problem, and i am unable to see that problem unless you raise this doubt under that problem only. please recheck.

thanks.

this solution seems to be of book allocation problem.
and your problem lies in check function.
incorporate above changes made in check function.

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.