#P1853. 投资的最大效益
投资的最大效益
Description
For example, consider the following two types of bonds:
- Investment amount , annual interest .
- Investment amount , annual interest .
Initially, with a total of in assets, he can invest in two units of Bond 1 and earn in interest in one year. Alternatively, investing in one unit of Bond 1 and two units of Bond 2 yields in interest in one year; after two years, the total interest is , bringing total assets to . Then, by selling one unit of Bond 2 and switching to Bond 1, the annual interest can reach . After the third year, total assets reach , at which point he can purchase three units of Bond 1, yielding an annual interest of . After the fourth year, total assets reach .
Given several types of bonds and the initial total assets, help Mr. John compute the maximum possible total assets after years of investment.
Input Format
The first line contains three positive integers , representing the initial total assets, the number of years, and the number of bond types, respectively.
The next lines each describe one type of bond. Each line contains two positive integers , representing the investment amount and the annual interest of the bond, respectively.
Output Format
Output a single integer, the maximum total assets after years.
10000 4 2
4000 400
3000 250
14050
Hint
For of the testdata, , , , , is a multiple of , and does not exceed of .
Translated by ChatGPT 5
京公网安备 11011102002149号