Two of the test case don’t pass plz help

#include
// #include
using namespace std;
bool is_possible(int arr[],int n,int k,int t,int mid){
int x=0;
int cnt=0;
for (int i = 0; i < n; i++)
{
x+=arr[i];
if (x>mid && arr[i]<=mid)
{
x=arr[i];
cnt++;
if (cnt==k)
{
return false;
}
}
else if(arr[i]>mid){
return false;
}
// cout<<x<<" ";
}
return true;
}
int main() {
int n,k,t;
cin>>n>>k>>t;
int arr[n];
int sum=0;
int s=0;
for (int i = 0; i < n; i++)
{
cin>>arr[i];
sum+=arr[i];
s=max(s,arr[i]);
}
// sort(arr,arr+n);
int end=sum;
int ans=0;
while (s<=end)
{
int mid=(s+end)/2;
if (is_possible(arr,n,k,t,mid))
{
ans=mid;
end=mid-1;
}
else{
s=mid+1;
}
}
cout<<(ans*t)% 10000003;
return 0;
}

Hi Pratham… just use long long int… it will pass all test cases
I have corrected ur code https://ide.codingblocks.com/s/593330 its working fine

Thank you for the help

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.