Happiness
There is a hostel with $M$ rooms arranged in a **circular clockwise** order as shown below: Each room can accommodate any number of students. $N$ students are allotted rooms in the hostel such that the $i^{th}$ student is initially allotted room $A_i$. If the $i^{th}$ student stays in the $j^{th}$ room, then his happiness will be $H_{i,j}$. We define the *total happiness* of the hostel as the **
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.
Sign in to chat with the tutor and save your progress.
Sign in to start