Failing all test cases except 1. Please help

#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);
//#define fr(i,n) for(int i=0; i<n; i++)
#define ll long long

bool possible(int arr[], ll n, ll k, ll t, ll mid)
{
int painters = 1;
int painted = arr[0];
for(int i=1; i<n; i++)
{
// cout<<painters<< " "<<painted<< “\n”;
if( (painted+arr[i])*t >mid )
{
painters++;
painted = arr[i];
}
else
painted += arr[i];
if(painters > k)
return false;
}
// cout<<“painters “<<painters<<”\n\n”;
return true;
}

int main()
{
fast
int n, maxlength=0;
long long k, t, totallength=0;
cin>>n>>k>>t;
int arr[n];
for(int i=0; i<n; i++)
{
cin>>arr[i];
totallength += arr[i];
maxlength = max(arr[i], maxlength);
// cout<<arr[i]<<" “;
}
// cout<<”\n";
// cout<<“maxlength “<<maxlength<<”\n”;
long long start = 0, end = totallengtht, ans = LLONG_MAX;
while(start<=end)
{
long long mid = (start+end)/2;
// cout<<start<<" “<<mid<<” "<<end<< “\n”;
if((maxlength
t) > mid) {
start = mid + 1;
continue;
}
// cout<<“check\n”;
if(possible(arr, n, k, t, mid))
{
ans = mid;
end = mid -1;
}
else
start = mid + 1;
}
cout<<ans;
};