EDITORIAL to MAXEP Problem - December Long 2018

@pshrimal000

Maybe your intent was correct to share a code along with the approach… But the way your code is written ; Its toooooo hard to read…

Maybe the better alternative would be to provide a link to your code (From some submission somewhere) .

Do give a thought to that…!!! Thanks…

1 Like

In my code , I used random function as a way to get an arbitrary no as specified in one of the constraints.
Here is my code : https://www.codechef.com/viewsolution/21905623

@shoom, I stand corrected. It appears that it is possible to design an algorithm where the total maximum cost is less than 400 coins in the worst case scenario.

I have two questions.

  1. How did we came up with x^A + x^B ?

  2. How do we solve x^A + x^B ?

yes please @utaha ( Or anyone who got that )… why is that equation correct and how do we solve that equation…???

I think using srqt decomposition would be better, as you only need to burn the panel 2 times to find the right voltage, regardless of the cost.
This seems more likely what one would do in real life, instead of burning the panel many times for no reason as happens in binary search approach (with ratio)…

Can you please tell how you derived the ratio??

#@allenjv123

I shared a link to that ratio determining code in the editorial above under the heading ‘Key Sentence’ ; well I can share that code again for you HERE ( Remember this is Python code - 2.7 version ).

You can run the code online or test in locally for a better understanding.

This code actually tells that what would be the array size after 5 steps if you keep on dividing the array in ratio 1:k ( where k in the code is 3.5 ) and every-time discard the right half.

And I have explained in the editorial itself as to why would this ratio work. You should read that.

On How I derived 3.5 :

What I explained in ‘Why will that ratio work’ and the concept of shift from binary search to linear search was in my mind beforehand. So actually I ended upon writing that code generalised for 1:k, Applied some hit and trials ( With k=1,2,3…(Actually I dont remember my trials) and finally ended up with k=3.5 ).

*So I didn’t derive it, rather it was like maybe this ratio thing will work ; Wrote a ratio code and did hit and trials to what that ‘k’ can be instead of deriving it in some mathematical way. And I proceeded with k=3.5 when I saw that after 5 operations ; I was left with array size 82 ( From code ) and had 1000-(150+1)5=245 coins left ; enough to shift from binary to linear search with a scope of one more burn in the linear search)

Still if you have any doubts , or wanted to ask something ; feel free to ask brother ; no Problem at ALLLL :slight_smile: …!!!

(Just be more specific about your doubt that what exactly you want to ask…)

But once again no problem at all. Hope this helps…