In this question, the element should be removed and put in i-1 and i+1 terms at same time ??
The total sum of elements in array acc to test case if 72.
so every position should get 9.
Can you please tell me how 23 operations get it??
Balife greedy Problem
hi @ashwani225 you can shift only 1 operation at a time
so if an array is like {2,8,2} in one step you can reach {3, 7, 3} -> {4,6,4} -> {5,5,5}
I hope you can see why we will need 3 steps to get to the valid configuration and cannot do so directly in one step.
If you need to see more test cases you can see the problem on SPOJ https://www.spoj.com/problems/BALIFE/
hi @ashwani225 stop your program after it prints “-1” else it will print max_load as well.
See for this example
8
16 17 15 0 20 1 1 3
the output is
-1
23
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.