I am not getting correct solution

#include
using namespace std;

bool cook(int p,int c,int r[],int mintime)
{
int pratacounter=0;
for(int i=0;i<c;i++)
{
int n=1;
int totaltime=0;
while(totaltime<=mintime)
{
totaltime+=n*r[i];
n++;
pratacounter++;
}
pratacounter–;
}
if(pratacounter>=p)
{
return true;
}
else
{
return false;
}
}

int main()
{
//no of prata cook and rank of cook array
int p,c,r[50];
cin>>p;
cin>>c;
//input values in increasing order of ranks so that sort algo na lagani pade is program me
for(int i=0;i<c;i++)
{
cin>>r[i];
}

``````    //binary search algo
int s,e,mid;

s=0; //minimum time to make all prata assume
e=r[0]*p*(p+1)/2; //min time to make all prata by best cook alone
int ans=-1;

while(s<=e)
{
mid=s+e/2;
int cancook=cook(p,c,r,mid);
if(cancook)
{
ans=mid;
e=mid-1;
}
else
{
s=mid+1;
}
}
cout<<ans;
``````

}

please check my code and tell the problem

If you don’t know how to share it using ide.codingblocks.com you can also ask me that.

Hey there are lots of mistake in your code,

``````e= (2*arr[0]+(p-1)*arr[0])*p/2;
also while loop in the cook function is also not correct
``````

try to take reference from this code, and apply it in yours.