Sort the pairs in descending order based on the values.
Initialize a hash map to keep track of the count of each label in the subset.
Initialize variables for the total score and the count of items selected.
Iterate over the sorted pairs and for each pair:
a. Check if adding the current item would not exceed the useLimit for its label.
b. If it does not, add the item's value to the total score, increment the label count, and increment the number of items selected.
c. If the number of items selected reaches numWanted, break the loop.