← All problemsSign in

Mean and Median

CodeChefRating 1371Open on judge ↗

Chef has two numbers $X$ and $Y$. Chef wants to find three integers $A, B,$ and $C$ such that: - $-1000 \le A, B, C \le 1000$ - $mean([A, B, C]) = X$ - $median([A, B, C]) = Y$ Can you help Chef find such three integers? As a reminder, $mean([P, Q, R]) = \frac{P + Q + R}{3}$ and $median([P, Q, R])$ is the element at the $2^{nd}$ (middle) position after we sort $[P, Q, R]$ in non-decreasing order.

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