Editorial for BPC 1 J3 - Group Project
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Hint 1
Try to pair students with those of similar quality. For example, it would make sense to pair the worst student with the second worst, and the best with the second best.
Solution
If you sort the list of students, you will find the optimal pairings. Then you can iterate to find the number of complaints.
Proof: After optimally pairing up every student, look at a subset of 2 pairs. Let be paired with , and be paired with . Also, without loss of generality, let . If , then it is better to pair with . Therefore, in an optimal pairing, .
Comments