All the test cases are failing. What is wrong in my code?https://ide.codingblocks.com/s/261054
Painter problem challenge
hello @kohliaaru09
a) use long long
b) search space s=max element in array * T (since array is not sorted it can be anywhere)
I’m not getting what you’re saying in (b)

here u are intialising s with a[n-1]*T
but because array is not sorted , a[n-1] will not be maximum always.
so find max element in array and then initilaise ur
s= max_element * T
also initialise ur ans with e.
I’ve sorted the array now.
Still only one test case is passing.
Already used long long also
dont sort the array , because order of elements matters.
painter are only allowed to paint only contiguos blocks
Okay.All the test cases have passed.Thanks!
Still,I have one doubt.why did you suggest to initialise ans with e?
u have initialised ans with INT_MAX but ans can be greater than that.
maximum value that ans can attain is e that why i told u to initialise it with e