#abc356g. G - Freestyle
G - Freestyle
Score : points
问题陈述
高桥可以以 种不同的方式游泳。 当他以第 种方式游泳时,他每秒钟消耗 点体力,并且每秒钟前进 米。
回答 个查询。第 个查询如下:
- 确定是否可能在总体力消耗不超过 的情况下前进 米。如果可能,找出所需的最少秒数。
在这里,他可以自由地组合不同的游泳方式,并且切换方式的时间可以忽略不计。 具体来说,他可以按照以下步骤游泳:
- 选择一个正整数 ,一个长度为 的正实数序列 ,以及一个长度为 的整数序列 ,其中每个元素都在 和 (包括 和 )之间。
- 然后,按照顺序 以第 种方式游泳 秒。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
Takahashi can swim in different styles.
When he swims in the -th style, he consumes stamina per second and advances meters per second.
Answer queries. The -th query is as follows:
- Determine if it is possible to advance meters while keeping the total stamina consumption at most . If it is possible, find the minimum number of seconds required.
Here, he can freely combine different swimming styles, and the time to switch styles is negligible.
Specifically, he can swim using the following steps:
- Choose a positive integer , a sequence of positive real numbers of length , and a sequence of integers of length where each element is between and , inclusive.
- Then, swim in the -th style for seconds in the order .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines in total.
For the -th query, print the answer in the -th line as follows:
- If it is impossible to advance meters while keeping the total stamina consumption at most , print
-1
. - Otherwise, print the minimum required time. The output is considered correct if the absolute or relative error between the printed value and the true answer is at most .
Sample Input 1
4
1 2
2 3
3 3
4 4
5
4 7
7 7
49 100
1000 500
4 5
Sample Output 1
3.000000000000000000
1.750000000000000000
-1
125.000000000000000000
1.500000000000000000
In this input, Takahashi can swim in the following four styles:
- Consumes stamina and advances meters per second.
- Consumes stamina and advances meters per second.
- Consumes stamina and advances meters per second.
- Consumes stamina and advances meters per second.
This input contains five queries.
- For the first query, .
- Choose and . Takahashi swims as follows:
- In the first second, he consumes stamina and advances meters.
- In the next seconds, he consumes stamina and advances meters.
- In total, he consumes stamina and advances meters. The required time is seconds, which is the minimum.
- Choose and . Takahashi swims as follows:
- For the second query, .
- Choose and . Takahashi swims as follows:
- In the first seconds, he consumes stamina and advances meters.
- In total, he consumes stamina and advances meters. The required time is seconds, which is the minimum.
- Choose and . Takahashi swims as follows:
- For the third query, .
- No matter how Takahashi swims, it is not possible to advance meters while keeping the total stamina consumption at most .
- For the fourth query, .
- Choose and . Takahashi swims as follows:
- In the first seconds, he consumes stamina and advances meters.
- In total, he consumes stamina and advances meters. The required time is seconds, which is the minimum.
- Choose and . Takahashi swims as follows:
- For the fifth query, .
- Choose and . Takahashi swims as follows:
- In the first seconds, he consumes stamina and advances meters.
- In the next second, he consumes stamina and advances meters.
- In total, he consumes stamina and advances meters. The required time is seconds, which is the minimum.
- Choose and . Takahashi swims as follows: