← All problemsSign in

Random Chocolates

CodeChefRating 2450Open on judge ↗

We all know that Chef got a box of $N$ chocolates (numbered $1$ through $N$) as his birthday present. For each valid $i$, the $i$-th chocolate has a sweetness value $W_i$. Chef is going to play the following randomised game for fun with his brother: - First, an integer $k$ between $1$ and $N$ (inclusive) is chosen uniformly randomly. - Then, $k$ times, Chef chooses a chocolate from the box unifo

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