시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 9 | 4 | 4 | 50.000% |
You have a food processor with a variety of blades that can be attached to it, as well as some food you would like to process into smaller pieces.
The food processor can have one blade attached at any time. Each blade processes food by reducing its average piece size at a particular exponential rate, but it also has a maximum average piece size requirement; if the average piece size of the food is too big for the blade, the food processor will get stuck. Given a starting average food piece size, a target average piece size, and a set of blades for your food processor, determine the minimum amount of processing time needed to process your food into the target average piece size.
Note that we only care about the time spent actively processing food; we do not track time spent switching out blades or loading/unloading the food processor.
The first line of input contains three integers $s$, $t$, and $n$ ($1 \le t < s \le 10^6, 1 \le n \le 10^5$), where $s$ is the starting average piece size, $t$ is the target average piece size, and $n$ is the number of blades.
Each of the next $n$ lines contains two integers $m$ and $h$ ($1 \le m, h \le 10^6$). These are the blades, where $m$ is the maximum average piece size of the blade and $h$ is the number of seconds the blade needs to halve the average piece size.
Output a single number, which is the minimum amount of time in seconds needed to process the food to the target average piece size. If it is not possible to reach the target, output $-1$. Your answer should have a relative error of at most $10^{-5}$.
10 1 2 10 10 4 5
23.219281
10000 9999 1 10000 1
1.4427671804501932E-4
ICPC > Regionals > North America > Mid-Atlantic Regional > 2022 Mid-Atlantic USA Regional Contest > Division 2 K번
ICPC > Regionals > North America > South Central USA Regional > 2022 South Central USA Regional Contest > Division 2 K번
ICPC > Regionals > North America > Southeast USA Regional > 2022 Southeast USA Regional Programming Contest > Division 2 K번
ICPC > Regionals > North America > Mid-Central Regional > 2022 Mid-Central USA Regional Contest F번
ICPC > Regionals > North America > Pacific Northwest Regional > 2022 ICPC Pacific Northwest Region > Division 1 F번
ICPC > Regionals > North America > Pacific Northwest Regional > 2022 ICPC Pacific Northwest Region > Division 2 F번
ICPC > Regionals > North America > Rocky Mountain Regional > 2022 Rocky Mountain Regional Contest F번