← All problemsSign in

Group Assignment

CodeChefRating 1092Open on judge ↗

Chef is hosting a party at his house and $N$ people are invited to it. Everyone has arrived and they are eager to make a group and chit-chat. The $i^{th}$ person prefers to be in a group of **exactly** $P_i$ people (including himself). A person who is not in a group of preferred size gets upset. Find whether Chef would be able to assign every person to a group such that everyone remains happy. #

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