Code Review Needed Answer Is Not Coming Right

#include <bits/stdc++.h>
using namespace std;
bool isCheck(long long int *arr,long long int n,long long int mid,long long int count,long long t)
{
long long int sum=0;
int painter=0;
for(long long int i=0;i<n;i++)
{
if(((sum+arr[i]*t))>mid)
{
painter++;
sum=0;
}
sum+=arr[i]*t;
}

if(painter>count)
{
    //cout<<"painter:"<<painter<<endl;
    //cout<<"yes"<<endl;
    return false;
}

return true;
}
long long int binary_method(long long int *arr,long long int lower,long long int higher,long long int prev_mid,long long int k,long long int time,long long int n)
{
//cout<<lower<<" “<<higher<<endl;
if(lower>higher)
{
//cout<<“inside”;
return prev_mid;
}
long long int mid=(lower+higher)/2;
if(isCheck(arr,n,mid,k,time))
{
//cout<<mid<<endl;
//cout<<lower<<” "<<higher<<endl;
//cout<<“U”<<endl;
if(prev_mid>mid)
{
prev_mid=mid;
//cout<<mid<<endl;
}
return binary_method(arr,lower,mid-1,prev_mid,k,time,n);
}

else
{
    //cout<<"in"<<endl;
    return binary_method(arr,mid+1,higher,prev_mid,k,time,n);
}

}
int main()
{
long long int n,k,t;
cin>>n>>k>>t;
long long int *arr=new long long int[n];
long long int max=0,higher_time=0,lower_time=0;
for(int i=0;i<n;i++)
{
cin>>arr[i];
if(arr[i]>max)
{
max=arr[i];
}

    higher_time+=arr[i];
}
higher_time*=t;
lower_time=max;
lower_time*=t;
//cout<<lower_time<<" "<<higher_time<<endl;
long long int prev_mid=LLONG_MAX;

long long int ans=binary_method(arr,lower_time,higher_time,prev_mid,k,t,n);
cout<<ans;
return 0;
}

hi
save your code to online ide of coding blocks and then post the link here

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.