Two of the test cases failing

#include<bits/stdc++.h>
using namespace std;
bool pos(int a,int mid,int req,int n)
{
int k=0,cf=0;
for(int i=0;i<n;i++){cf+=a[i];
if(cf>mid){cf=a[i];k++;}
}if(k>req){return false;}
return true;
}
int main ()
{
int n,p,k;int mid;
cin>>n>>p>>k;int a[n];int mx=0;int total=0;
for (int i=0;i<n;i++)
{
cin>>a[i];total+=a[i];mx=max(a[i],0);
}
int s=mx;
int e=total;int ans;
while(s<=e){
mid =(s+e)/2;
if (pos(a,mid,p,n)){ans=mid;e=mid-1;}
else{s=mid+1;}
}
cout<<(k
ans)%10000003;
return 0;
}

I have edited your code… Try to submit it now…