Getting two test case wrong

bro,
There is a mismatch of the input variable u have taken n >> k >> t is what u have taken
but the question provided us with first max no of painter then n size of board

secondly, there is problem in isValid there initally the no of painter need to be 1

Please try figuring out the code, these were the major bug points,

in case of doubt do ask

with starting painter=1 i am getting incorrect result of given example

using cin>>k>>n>>t still getting wrong answer

IF we are on the same page we are talking about this problem
https://hack.codingblocks.com/app/contests/133/p/716
It taked 3 input k , n , then n array elements

This question stated that **takes 1 unit of time to paint 1 unit of boards **

Also the no of painter has to be 1 initially as i told that minimum no of painters need to be atleast 1 to get the work to start

You please refer to the below code to see the points where your code fails

You have to paint N boards of length {A0, A1, A2, A3 … AN-1}. There are K painters available and you are also given how much time a painter takes to paint 1 unit of board. You have to get this job done as soon as possible under the constraints that any painter will only paint contiguous sections of board. Return the ans % 10000003 Input Format First line contains three space seperated integers N,K and T ,where N = Size of array, K = No of painters available , T = Time taken to print each board by one painter Next line contains N space seperated positive integers denoting size of N boards. Constraints 1<=N<=100000 1<=K<=100000 1<=T<=1000000 1<=Li<=100000 Output Format Return minimum time required to paint all boards % 10000003. Sample Input 2 2 5 1 10 Sample Output 50 Explanation The first painter can paint the first board in 5 units of time and the second painter will take 50 units of time to paint the second board. Since both can paint simultaneously , the total time required to paint both the boards is 50.

still confused with my code. i think logic is same as of your code but cant find error in mine please help

Hey, i see so many differences.

->>no of painters initially need to be 1
->> The following lines of code are not required.
if(currentsum){
painter++;
if(painter>k)
return false;
}

i got the answer, actually i was using sort function which could increase the time. after removing it i got all test cases correct

1 Like

great thanks for pointing out the mistake.

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.