Problem: the idols of Mahabalesh (MBIDOL)

Can anyone explain how to approach this problem.
This problem was a part of contest #include techweed.h

u have to go to each cell and calculate minimum range from that cell . using binary search.

1 Like

Can you please explain your approach for ?

I got your approach.Thanks for sharing.

this is totally greedy question.
as firstly u will see if there is any subarray of length k whose sum is zero. then answer will always be -1.
now lets take first block of ‘k’ length. now if its sum is lesser than m so in this we have to update .
now if u are on ith pos. then firstly u will see greedily if u will update (i+k-1)th block with infinity value. then maximum blocks will cover. now (corner case possible this (i+k-1) th index value is 0 , so move to i+k-2 th index… and so on, until u get non zero value).so the index which u have updated recently ,let it be j, so update j, j+1, j+2…K BLOCKS with infinity value now jump to next index(means which is not updated yet) and repeat the procedure.



Can u explain the question MORALE99

I wonder how can somebody think and code solution to this "not so easy " problem in just 2 minutes ,god speed :sweat_smile:

1 Like