#t395. 竞赛总分(inflate)
竞赛总分(inflate)
Contest Score (Inflate)
Problem Background
Special for beginners, ^_^
Problem Description
The more points students score in our USACO contest, the happier we are. We try to design our contest so people can score as many points as possible.
Now a contest will be held. The total time is fixed, and there are several types of problems to choose from. You may choose any number of problems of each type. Each type has a score (points earned) and a time (time needed). Choose some problems so that the total time does not exceed and the total score is maximized.
The input includes the contest time and the number of problem types .
Each following line describes one "problem type" with two integers: the first is the points for solving this type (), the second is the time needed ().
Input Format
Line 1: two integers — the contest time and the number of problem types .
Lines : two integers each — the score and time of each problem type.
Output Format
A single line with the maximum score achievable within the given fixed time.
Sample Input
300 4
100 60
250 120
120 100
35 20
Sample Output
605
Constraints
, , , .
Time limit 1s, memory limit 1024KiB for each test case.
Hint
One way to reach 605: choose two problems of type 2 and three problems of type 4.