#P1616. 疯狂的采药
疯狂的采药
Description
LiYuxiang is a bright child, and his dream is to become the greatest physician in the world. To achieve this, he wants to apprentice under the most respected physician nearby. To assess his aptitude, the physician gave him a challenge. The physician took him to a cave full of herbs and said: "Child, there are different kinds of herbs in this cave. Picking each kind takes some time, and each has its own value. I will give you a period of time. Within this time, you may pick some herbs. If you are clever, you should be able to maximize the total value of the herbs you collect."
If you were LiYuxiang, could you complete this task?
Differences from the original problem:
. Each kind of herb can be picked an unlimited number of times.
. There are many kinds of herbs, and the total picking time can be very long. The master has been waiting for a very long time!
Input Format
The first line contains two integers, representing the total time available for picking herbs and the number of herb types .
Lines through each contain two integers. On line , the integers denote the time to pick the -th type of herb and the value of this herb, respectively.
Output Format
Output one line containing a single integer, which is the maximum total value of herbs that can be collected within the allotted time.
70 3
71 100
69 1
1 2
140
Hint
Constraints
- For of the testdata, it is guaranteed that .
- For of the testdata, it is guaranteed that , , and , .
Translated by ChatGPT 5
京公网安备 11011102002149号