[Huawei OD machine test 2023 latest] maximum reward (100% C language problem solution)

topic description

Xiao Ming will get his own work list every week when he goes to work. The work list contains n tasks, and each task has a corresponding time-consuming time (unit h) and remuneration. The total remuneration of the job is the sum of the remuneration of all completed tasks , then please help Xiao Ming arrange work to ensure that Xiao Ming can maximize his work income within the specified working hours.

enter description

The first line of input is two positive integers T, n.
T represents the working hours (unit h, 0 < T < 1000000),
n represents the number of jobs (1 < n ≤ 3000).
Next are n lines, each containing two integers t, w.
t represents the duration of the work (unit h, t > 0), and w represents the reward for the work.

output description

Output the maximum remuneration that Xiao Ming can get for working within the specified working hours.

Example

enter 40 3
20 10
20 20
20 5

Guess you like

Origin blog.csdn.net/shangyanaf/article/details/130484658