Editorial for VPEX P2 - Darcy Parties

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.

Whenever a person sells cake to another person, the total amount of cake does not change. So you can find the amount of cake everyone starts off with by dividing the total amount by the number of people.

If someone sells cake, they will have less than they started with. If someone buys cake, they will have more. No one will buy and sell because you can't like and dislike cake at the same time. Count the number of people who do not have the amount they started off with to get your answer.

Time Complexity: \mathcal{O}(N)


There are no comments at the moment.