Painters partition problem

please suggest some modifications in my code its not passing 3test cases
#include
#include
using namespace std;
bool possible(int board[],int mid,int k,int n){
int cnt=1;

int time=0;
for(int i=0;i<n;i++){
	
	if(time+board[i]>mid){
		cnt++;
		time=board[i];
		if(cnt>k){
			return false;
		}
		
		
		
		
	}
	else{
		time+=board[i];		}
	
	}
	return true;

}

int main() {
int k,n;
cin>>k>>n;
int len_board[n];
for(int i=0;i<n;i++){
cin>>len_board[i];
}
long long sum=0;
for(int i=0;i<n;i++){
sum += len_board[i];
}
sort (len_board,len_board+n);

int ans;
int s=len_board[n-1];
int e=sum;
while(s<=e){

	int mid=(s+e)/2;
	bool boardHoGaya= possible(len_board,mid,k,n);
	

	if( boardHoGaya){
		ans=mid;
		e=mid-1;
	}
	else{
		s=mid+1;
	}

}
cout<<ans;

return 0;

}

@deepakjumani09
hello Deepak,


a) dont sort ur array
b) use long long datatype to avoid overflow
c) multiply ur answer with T and take mod

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.