题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3230
Programming is fun, Aaron is addicted to it. In order to improve his programming skill, he decides to solve one programming problem per day. As you know, different problems have different properties, some problems are so difficult that there are few people can solve it, while some problems are so easy that almost everyone is able to tackle it.
Programming skill can be measured by an integer p. And all problems are described by two integers ai and bi. ai indicates that if and only if P >= ai, you can solve this problem. bi indicates that after you solve this problem, your programming skill can be increased by bi.
Given the initial programming skill p of Aaron, and the information of each problem, Aaron want to know the maximal programming skill he can reach after m days, can you help him?
Input
Input consists of multiple test cases (less than 40 cases)!
For each test case, the first line contains three numbers: n, m, p (1 <= n <= 100000, 1 <= m <= n, 1 <= p <= 10000), n is the number of problems available for Aaron,m, p as mentioned above.
The following n lines each contain two numbers: ai and bi (1 <= ai <= 10000, 1 <= bi <= 10000) describe the information of the i-th problem as memtioned above.
There's a blank line between consecutive cases.
Output
For each case, output the maximal programming skill Aaron can reach after m days in a line.
Sample Input
2 2 1 1 2 7 3 3 1 2 1 2 2 3 3 4
Sample Output
3 5
题意:
给出Aaron 的初始的做题能力值,然后给出N道题:Aaron 解决这道题至少需要多少能力值a,Aaron 解决了这道题他能增加多少能力值b!
求M天后Aaron 的最大能力值是多少!
PS:
运用优先队列,分别对a和b排序一下!
代码如下:
//#pragma warning (disable:4786)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include