Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
To maximize the number of kinds of candies, we should try to distribute candies such that Alice will gain all kinds.
What is the upper limit of the number of kinds of candies Alice will gain? Remember candies are to distributed equally.
Which data structure is the most suitable for finding the number of kinds of candies?
Will hashset solves the problem? Inserting all candies kind in the hashset and then checking its size with upper limit.