• + 3 comments

    Hi all, I would like to give you my feedback about the exercice and the difficulties I have experimented for those who are really stuck. Unfortunatelly I didn't success to implement a solution so I checked on the Editorial.

    First of all it was not obvious that having two players is "fake". In fact only the first player have the "power" to optimize the maximum solution (because he plays first) and the second one shall deal with the remaining problem (it is because the first player takes X bricks than the second player will take the Y next bricks). The biggest difficulty is to see the second player as a subplayer of yourself which wants to do the same as you (as a "clone") ie get the maximum score. A proof? Finaly you can play alone this game. Easier no?

    Then how to build the right algorithm? I will not give you the solution but some tips to keep in mind. I am a beginner with DP and the main issue I meet is to formalize the problem a mathematically way. You have to find the "magic" formula which is computed for i_th -1 and keep true at i_th (cf https://en.wikipedia.org/wiki/Recurrence_relation). More specifically when the first player wants to pick the i_th brick what does it mean for the previous solution? What should keep true at i_th? Remember: previous solutions are optimal and you have to indistinguishably consider the two players.

    I hope this is helpful. Good luck!