Editorial for APIO '10 P1 - Commando
Submitting an official solution before solving the problem yourself is a bannable offence.
Solution 1
: Using dynamic programming, let
indicate the maximum battle effectiveness after adjustment. We have transfer equations below:
Such a solution should score around .
Solution 2
: Use pre-calculated partial sum to accelerate the solution above. Let
, we have
.
Such a solution should score around .
Solution 3
: Consider two decisions
, we choose
instead of
if and only if:
Thus, we can use a queue holding all necessary decisions. Each decision in the queue is the best decision during a specific range of . When a decision is to be made, we simply begin searching at one end of the queue, and find the first decision where
is in its range. After that, we put decision
at the other end of the queue as a new decision, updating the range of decisions before it using the inequality above.
Such a solution should score .
Comments