← All problemsSign in

Expected Cost

CodeChefRating 2038Open on judge ↗

You are on a one-dimensional number line, initially at $x = 1$. You want to reach $x = N + 1$. You can do the following $2$ actions when you are at $x (x \le N)$: - Pay a cost of $A_x$ and move to $x + 1$. - Pay a cost of $B_x$ and move to a random position among the positions $x = 1, 2, \ldots, N + 1$. All of the $N + 1$ possibilities are equiprobable. Find the minimum expected cost to reach $

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start