#P12966. [CCO 2025] Asteroid Mining
[CCO 2025] Asteroid Mining
题目描述
It is the year 2017 and Ryan is an asteroid miner. He makes a living by mining asteroids and selling them at the CCO (Celestial Cargo Outpost).
On his latest mining expedition, he has mined mineral chunks where the -th chunk has a value and a mass . Ryan plans to transport a set of chunks to the CCO with his rocket, but he only has enough fuel to last one more trip. He calculated that the maximum total mass he can safely carry on his rocket is . Due to Ryan's mining technique, the chunks exhibit a special property: for any two mineral chunks, one's mass is divisible by the other chunk's mass.
Help Ryan find the maximum total value he can ship to CCO while adhering to his rocket's constraints.
输入格式
The first line will contain two space-separated integers () and ().
The next lines will each contain two space-separated integers () and (), representing the value and mass of the -th mineral chunk respectively. Additionally, for any two mineral chunks (), either or , where means that is a divisor of (i.e., is an integer).
输出格式
On one line, output one integer, the maximum total value Ryan can ship to CCO.
6 10
1 1
5 2
200 6
9 2
6 2
100 1
310
提示
Sample Explanation
Ryan can take all the chucks except the second and fifth chucks to achieve a total value of . Note that the total mass of the chunks is . We can show that this is optimal.
The following table shows how the available marks are distributed:
Marks Awarded | Bounds on | Bounds on | Additional Constraints |
---|---|---|---|
2 marks | None | ||
4 marks | |||
6 marks | |||
2 marks | All are equal. | ||
3 marks | At most 2 distinct . | ||
6 marks | None |