#P13010. 【MX-X13-T5】「KDOI-12」茫茫人海如都市的晚高峰,迎面的车终将相遇,迎面的车终将分别。

    ID: 12740 远端评测题 2000ms 512MiB 尝试: 1 已通过: 1 难度: 7 上传者: 标签>贪心二分Special JudgeO2优化梦熊比赛

【MX-X13-T5】「KDOI-12」茫茫人海如都市的晚高峰,迎面的车终将相遇,迎面的车终将分别。

Description

A main road has two directions: from north to south and from south to north, denoted as direction 11 and direction 22, respectively.

Each direction has one base lane. Additionally, the road has nn dynamic lanes.

A day consists of mm moments, numbered from 11 to mm, where at the ii-th moment, ci,jc_{i, j} cars pass through direction jj.

At each moment ii, each dynamic lane jj can be in one of three states, denoted as ti,jt_{i, j} (ti,j{0,1,2}t_{i, j} \in \{0, 1, 2\}).
If ti,j=0t_{i, j} = 0, 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 CC represents the time required to switch the direction of a dynamic lane.
Specifically, if the direction of dynamic lane jj is decided to switch between moment xx and x+1x + 1 (where tx,j0t_{x, j} \ne 0),
then for y[x+1,x+C]y \in [x + 1, x + C], ty,j=0t_{y, j} = 0. Starting from moment x+C+1x + C + 1 (until the next switch), t,jt_{*, j} becomes 3tx,j3 - t_{x, j}.

As a special case, for the first moment (11), the direction of each dynamic lane can be directly assigned.

Define the load vi,jv_{i, j} of direction jj at moment ii 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 TT, the number of test cases. For each test case:

  • The first line contains three positive integers n,m,Cn, m, C.
  • The second line contains mm positive integers c1,1,,cm,1c_{1, 1}, \ldots, c_{m, 1}, representing the number of cars passing through direction 11 at each moment.
  • The third line contains mm positive integers c1,2,,cm,2c_{1, 2}, \ldots, c_{m, 2}, representing the number of cars passing through direction 22 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 10610^{-6}.

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 t1,1=2t_{1, 1} = 2, t2,1=0t_{2, 1} = 0, and t3,1=1t_{3, 1} = 1. Then, $v_{1, 1} = v_{1, 2} = v_{2, 1} = v_{2, 2} = v_{3, 2} = 1$, and v3,1=1.5v_{3, 1} = 1.5. The maximum load is 1.51.5. It can be proven that no allocation yields a better result than 1.51.5.

【Data Range】

This problem uses bundled testing.

Subtask ID Points nn\leq CC\leq m\sum m\leq
11 1515 11 m1m-1 5×1055\times10^5
22 2020 10510^5 11
33 1515 m1m-1 100100
44 2020 5×1045\times10^4
55 3030 5×1055\times10^5

For all data:
1T1041 \leq T \leq 10^4,
1n1051 \le n \le 10^5,
1ci,1,ci,21051 \le c_{i, 1}, c_{i, 2} \le 10^5,
1C<m5×1051 \le C < m \leq 5 \times 10^5,
m5×105\sum m \le 5 \times 10^5.


Translated by DeepSeek V3.