Painter problem

sir its not passing all the test cases:

#include
#include
#include
using namespace std;
bool isPossible(long long int n , long long int k , long long t , long long int arr[],long long int mid)
{
int time=0,painter=1;

for(int i=0;i<n;i++)
{
	
	time+=(arr[i]*t);
	if(time>mid)
	{
		++painter;
		if(painter>k)
		  return false;
		
		
		time=0;
		--i;
		
		
	}

	
   


}
return true;

}
int min_time(long long int n ,long long int k , long long int t , long long int arr[])
{
long long int s=0,min_time1=INT_MAX;
long long int e=0;
for(int i=0;i<n;i++)
{
s=max(arr[i],s);
e+=arr[i];
}
s*=t;
e*=t;
while(s<=e)
{
long long int mid=(s+e)/2;
if(isPossible(n,k,t,arr,mid))
{
min_time1=min(min_time1,mid);
e=mid-1;
}
else
s=mid+1;
}
return min_time1;
}
int main()
{
long long int n , k,t;
cin>>n>>k>>t;
long long int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];

cout<<min_time(n,k,t,arr)%10000003;

}

please help

you have taken mod at the end
may be you ans overflow the int
so best practice is to take mod at each step

Please share your code link it is difficult to find mistake 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.