I am getting wrong answer.
Balife from Greedy
for(int i=0;i<n;i++)
{
diff+=(a[i]-load);//removed abs
// diff=max(diff,-1*diff);removed this
ans=max(ans,abs(diff));//added abs
}
I am still getting WA for the sample case
I have a doubt this is exactly similar to load balancer right??
Because we were following the same approach there also.
But, in that question we could divide our load between i+1 and i-1 at the same time but here it’s only allowed to divide our load between i+1 or i-1 at one time.
Yeah …
So, whenever I have to divide numbers equally in each cell. I’'ll use this approach?
yup in most of the quest.
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.