Painters Problem


2 test cases are not clearing, I know there is some problem associated with data overflow as i have avoided ll and in place of it took MOD at every possible overflow case, still confused why and where im data is getting overflowed , please answer this doubt to the point as i know using long long will resolve the problem , thank you

this is not correct approach to take mode in binary search
for (int i = 0; i < n; ++i)
{
e = (e + boards[i]) % MOD;
s = max(s, boards[i]);
}
if you do so then e may be less than s

taking mod with s and e will give you wrong ans
as you are changing the search space in binary search

use long long int there is no problem with ll
why you are avoiding to use ll??

if data is large best is to use ll

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.