1301: news reporter

内存限制:64 MB 时间限制:2.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

There are n(1n5000) big events happened in the community, with the ith event a postive energy value ai and a negative energy value bi. As an experienced news reporter, you want to choose at least K events e1,e2,...,eK and maximize harmonious value

It is guaranteed that there are at most K1 events whose negative energy value is 0.
Better yet, you have just learned how to increase the base of positive energy, which means you can add an integer
c(c>0) to all the events' positive energy value at your will. You think that skill can make harmonious value even bigger.
However, the public is aware of your trick. If the harmonious value is too big (greater or equal to
lim), they will regard H as H mod lim. So be careful to use your trick, if your report deviates you will have to take responsibility!

输入

Multiple test cases. For each case:

  • The first line contains three integers n,K,lim(1≤Kn≤5000,1≤lim≤106);
  • The second line contains n integers a1,a2,..,an(0≤ailim);
  • The third line contains n integers b1,b2,..,bn(0≤bilim);

输出

For each test case, output a real number in a single line, indicating the maximum value of H. Keep 7 decimal places.

样例输入 复制

5 3 10
1 2 3 4 5
1 2 3 4 5

样例输出 复制

4.0000000