#P1842. [USACO05NOV] 奶牛玩杂技
[USACO05NOV] 奶牛玩杂技
Description
Each cow has its own weight and strength. Cow has weight and strength .
When a cow has other cows standing on her, she gets squashed to some extent. We call this her "squashed index." For any cow, her squashed index equals the total weight of all cows stacked above her (not including herself) minus her strength.
After the cows are stacked in some order, their overall squashed index is the squashed index of the most squashed cow.
Your task is to help the cows find an ordering that minimizes the overall squashed index.
Input Format
The first line contains an integer .
The next lines each contain two integers and .
Output Format
Output a single integer, the minimal overall squashed index.
3
10 3
2 5
3 3
2
Hint
Constraints: For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号