← All problemsSign in

Monks

CodeChefRating 1776Open on judge ↗

There is a town with $N$ people and initially, the $i^{th}$ person has $A_i$ coins. However, some people of the town decide to become *monks*. If the $i^{th}$ person becomes a monk, then: - He leaves the town thereby reducing the number of people in the town by $1$. - He distributes $X$ $(0 \le X \le A_i)$ coins to the remaining people of the town (not necessarily equally). Note that each monk can

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