AtlassianOA #3
Planning Production
估计中等可在线判题
考点(AI 标注)贪心调度
Before starting each product, cash must be at least its worst-case cost w, but only its expected cost e is actually deducted. Production can be arranged in any order; find the minimum initial cash needed to complete all products.
输入格式
The first line contains n, followed by n lines of w e. Complete original bounds: 1≤n≤100000, 1≤e≤w≤100000. Output an exact integer, not limited to 32 bits by the int in the original example signature.
输出格式
Output a single integer answer.
样例 1
输入:
2
5 1
4 3
输出:
5
样例 2
输入:
2
5 5
5 5
输出:
10
样例 3
输入:
1
1 1
输出:
1
样例说明
The outputs of the three public examples are, in order: 5; 10; 1. Verified by independent enumeration or direct simulation.