#P9977. [USACO23DEC] Bovine Acrobatics S
[USACO23DEC] Bovine Acrobatics S
Problem Description
Farmer John has decided to have his cows perform acrobatics. First, FJ weighed his cows and found that they have () distinct weights. Specifically, for all , there are cows whose weight is units (, ).
His most famous act requires the cows to form a balanced cow tower. A cow tower consists of some cows, where each cow stands on top of the next cow. A cow tower is balanced if and only if every cow being stepped on is at least () units heavier than the cow directly standing on it. Every cow may be used as part of a cow tower.
If FJ wants to create at most () cow towers, what is the maximum number of cows that can be used as part of the cow towers?
Input Format
The first line contains three space-separated integers , , and .
The next lines each contain two space-separated integers and . It is guaranteed that all are distinct.
Output Format
Print the maximum number of cows in the cow towers when FJ uses the best strategy.
3 5 2
9 4
7 6
5 5
14
3 5 3
5 5
7 6
9 4
9
Hint
Sample Explanation 1
FJ can use cows of weights to create four balanced cow towers, and then use cows of weights to create one more.
Sample Explanation 2
FJ can use cows of weights to create four balanced cow towers, and then use one cow of weight to create one more. Alternatively, he can use cows of weights to create four balanced cow towers, and then use one cow of weight to create one more.
Test Point Properties
- Test points satisfy and the total number of cows does not exceed .
- Test points satisfy that the total number of cows does not exceed .
- Test points have no additional constraints.
Translated by ChatGPT 5