传统题 2000ms 64MiB

news reporter

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

There are n(1≤n≤5000) 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 K−1 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!

Input Format

Multiple test cases. For each case:

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

Output Format

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

国庆训练赛

未参加
状态
已结束
规则
XCPC
题目
11
开始于
2017-10-1 20:00
结束于
2017-10-2 1:00
持续时间
5 小时
主持人
参赛人数
51