what is the error ???
Regarding the error
Hey @gargshivam2001
Your mintie function looks wrong, I rewrote it with comments
bool mintie(int a[], int m,int p,int key) {
int silver=0 ; //total pratas count
for (int i = 0; i < m; i++) {
int x = 1;
while ( (x * (x + 1)*a[i]) <= 2*key ) //Here pratas are made in arr[i] ,2arr[i] ,3arr[i] .... summation = x*(x+1)/2*a[i] so we are doing that here to find max x which satisfy that
x++;
x--;
silver += x ; //adding pratas by current chef to total answer
}
return (silver>=p);
}
Also to calculate end
int end=0; //updated
int k=1; //added
for(int i=1;i<=p;i++){//added
end+=k*a[m-1]; ..max rank chef makes all the paratas
++k;
}