#P2570. [ZJOI2010] 贪吃的老鼠

    ID: 1587 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2010二分网络流浙江Special Judge

[ZJOI2010] 贪吃的老鼠

Description

Recently, mm mice have appeared in the cheese shop. Their goal is to eat all the cheese produced. The shop produces nn pieces of cheese per day. The ii-th piece has size pip_i, is produced at second rir_i, and must be eaten before second did_i. Mouse jj eats at speed sjs_j, so if it eats the ii-th piece alone, it takes time pi/sjp_i / s_j. The mice have special eating rules:

  1. At any moment, a mouse can eat at most one piece of cheese.
  2. At any moment, a piece of cheese can be eaten by at most one mouse.

Because the shelf life of cheese is often short, to eat all pieces, the mice can use a magical spell to extend the shelf life. Extending the shelf life by TT seconds means every did_i becomes di+Td_i + T. Since the spell is costly, the mice want the minimum TT such that all cheese can be eaten.

Input Format

The first line contains an integer KK, the number of test cases.

For each test case, the first line contains two integers nn and mm, the numbers of cheese pieces and mice, respectively. The next nn lines each contain three integers pi,ri,dip_i, r_i, d_i. The final mm lines each contain one integer sjs_j. The meanings of pi,ri,di,sjp_i, r_i, d_i, s_j are as described above.

Output Format

Output KK lines. Each line contains a real number, the minimum TT you found. The absolute error between your answer and the standard answer must not exceed 10410^{-4}.

2
2 2
13 0 4
10 1 3
4
2
1 1
1 0 2
1

0.5
0

Hint

Sample Explanation:

For the first test case:

From second 00 to second 11: The first mouse eats the first piece of cheese.

From second 11 to second 3.53.5:

  • The first mouse eats the second piece of cheese.
  • The second mouse eats the first piece of cheese.

From second 3.53.5 to second 4.54.5: the first mouse eats the first piece of cheese.

Constraints:

  • For 30%30\% of the testdata, 1n,m51 \le n, m \le 5.
  • For 100%100\% of the testdata, 1K51 \le K \le 5, 1n,m301 \le n, m \le 30, 1pi1051 \le p_i \le 10^5, 0ri<di1070 \le r_i < d_i \le 10^7, 1sj1051 \le s_j \le 10^5.

Translated by ChatGPT 5