Painter problem

i cant fiind error in my program

There are few errors

  1. in the valid function : sum should be initialised to a[i] not to 0
    if(sum+a[i]>mid)
    {
    // sum=0;
    sum = a[i];
    pa++;
    if(pa > k)
    return false;
    }

  2. then the start in binary function should be from the greatest value of the array given.
    Since array is not sorted , so arr[n-1] is not always the greatest number

  3. return return (anst)%10000003; and not just anst

I DID WHAT YOU SAID BUT STILL 2 TESTCASES ARE NOT RUNNING


I have updated the code
Have a look

why are we using the %10000003 twice

now the first two cases are not running

bro please provide the question link

To avoid overflow
u can do it once as well. no issues, just used to be on the safer side i did it twice

question link: https://hack.codingblocks.com/app/contests/1161/p/1707

We were comittiing the most stupid mistake…

input order was incorrect

cin >> n >> k >> t;
we were till now taking k >> n >> t;

o yes even i didn’t noticed it

thank you so much <3

You are welcome.

Happy Coding