#P13010. 【MX-X13-T5】「KDOI-12」茫茫人海如都市的晚高峰,迎面的车终将相遇,迎面的车终将分别。
【MX-X13-T5】「KDOI-12」茫茫人海如都市的晚高峰,迎面的车终将相遇,迎面的车终将分别。
Description
A main road has two directions: from north to south and from south to north, denoted as direction and direction , respectively.
Each direction has one base lane. Additionally, the road has dynamic lanes.
A day consists of moments, numbered from to , where at the -th moment, cars pass through direction .
At each moment , each dynamic lane can be in one of three states, denoted as ().
If , it means the dynamic lane is impassable. Otherwise, its value indicates the direction allowed for passage.
The direction of dynamic lanes cannot be freely switched. A parameter represents the time required to switch the direction of a dynamic lane.
Specifically, if the direction of dynamic lane is decided to switch between moment and (where ),
then for , . Starting from moment (until the next switch), becomes .
As a special case, for the first moment (), the direction of each dynamic lane can be directly assigned.
Define the load of direction at moment as the ratio of the number of cars passing through this direction to the number of available lanes (including the base lane and dynamic lanes), i.e., $v_{i, j} = \frac{c_{i, j}}{1 + \sum_{k = 1}^n [t_{i, k} = j]}$.
Your task is to determine the minimum possible maximum load under a reasonable allocation scheme.
Input Format
There are multiple test cases in this problem.
The first line contains a positive integer , the number of test cases. For each test case:
- The first line contains three positive integers .
- The second line contains positive integers , representing the number of cars passing through direction at each moment.
- The third line contains positive integers , representing the number of cars passing through direction at each moment.
Output Format
For each test case, output a single line with a decimal number, representing the minimum possible maximum load.
This problem uses a custom checker. Your answer will be considered correct if its absolute or relative error compared to the correct answer is within .
4
1 3 1
1 1 3
2 1 1
1 5 2
1 2 2 1 3
3 2 1 2 2
2 5 1
2 3 1 3 3
2 1 3 1 1
3 6 2
3 5 2 4 1 6
2 3 4 5 6 1
1.5000000000
2.0000000000
1.5000000000
3.0000000000
Hint
【Sample Explanation】
For the first test case in the sample: Let , , and . Then, $v_{1, 1} = v_{1, 2} = v_{2, 1} = v_{2, 2} = v_{3, 2} = 1$, and . The maximum load is . It can be proven that no allocation yields a better result than .
【Data Range】
This problem uses bundled testing.
| Subtask ID | Points | |||
|---|---|---|---|---|
For all data:
,
,
,
,
.
Translated by DeepSeek V3.
京公网安备 11011102002149号