Chef and feast june 17 challenge

i dont understand why do i get wa in second case ?

1 Like

I am curious how did a 1 karma user asked a question :confused:

1 Like

same doubt here

You are getting WA because you didnt take care of how sort function sorts.

IT will sort in ascending order, i.e. from LEAST to GREATEST.

Take the sample case

-8 10 -2 0 0
Expected Output

You start by checking if (b[0]+sum) x (temp+1) is >ans.

Well, condition is correct,but to maximize, we should start by adding the “less negative” numbers (eg- -1, -2) first, and then the more negative ( eg- -10, -10000).

Your array b after sorting is {-8,-2}. Go from reverse direction (back to front, i.e. loop from i=n-1 to 0) and it should give you AC ^^

1 Like

also double post?

1 Like

@vijju123 sorry for late reply thanks though

i have the hax ,(no idea man i am just i did and i am happy to see that people answered ),also sorry for double post i recently read about the karma farming article on codechef and had no intension of doing so