Software Licenses
Time limit1sMemory limit128 MB
Schedule n licenses, one per month, when license i costs P_i * R_i^t if bought after t months, and minimize total cost.
- Level
Medium6 of 10
- Topics
- Greedy, Sorting, Math, Implementation
- Solved
- No attempts yet
Problem
You are launching a security company that must obtain licenses for different pieces of cryptographic software. Regulations let you obtain at most one license per month.
License currently sells for dollars, but every license appreciates along an exponential growth curve: the price of license grows by a factor of each month. Concretely, if you wait months before buying license (so means buying it in the first month at its current price), it costs dollars.
Because you may buy at most one license per month, obtaining all licenses takes exactly months: you buy exactly one license in each of the months . Decide which license to buy in each month so that the total amount paid is as small as possible, and report that minimum total cost.
Input
The first line contains a positive integer (), the number of licenses you must obtain.
Each of the next lines contains two numbers and (): the current price of license and its monthly growth factor.
Output
Print a single line containing the minimum total cost, rounded to two decimal places.