#P2722. [USACO3.1] 总分 Score Inflation
[USACO3.1] 总分 Score Inflation
Description
We can choose contest problems from several categories. Here, a "category" refers to a set of problems such that solving any problem in the set takes the same amount of time and yields the same score.
Your task is to write a program to tell the USACO staff how many problems to select from each category so that the total time spent solving problems is within the contest time limit and the total score is maximized.
Input Format
The first line contains two integers separated by a space, representing the contest duration and the number of categories .
Lines through each contain two integers separated by a space. On line , the integers denote the score awarded for a problem in category and the time required to solve it.
Since problems are grouped by category, you may select problems from the same category repeatedly.
Output Format
Output a single integer, the maximum total score.
300 4
100 60
250 120
120 100
35 20
605
Hint
Constraints
For of the testdata, it is guaranteed that , and .
Translated by ChatGPT 5
京公网安备 11011102002149号