← All problemsSign in

Pie Tasting

CodeChefRating 3322Open on judge ↗

Chef, who is a chef by profession as well, has created $N$ pies (enumerated $1$ through $N$) and has placed them in a row. Now he wants to taste all the pies, but by following a rather peculiar order of tasting. At each step, he chooses (uniformly randomly and independently) either the current leftmost pie or the rightmost pie, and eats that pie. For example, if $N = 7$, then one valid order of

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