天天看点

HDU 5281 Senior's GunSenior's Gun

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 616    Accepted Submission(s): 241

Problem Description

Xuejiejie is a beautiful and charming sharpshooter.

She often carries n guns, and every gun has an attack power a[i].

One day, Xuejiejie goes outside and comes across m monsters, and every monster has a defensive power b[j].

Xuejiejie can use the gun i to kill the monster j, which satisfies b[j]≤a[i], and then she will get a[i]−b[j] bonus .

Remember that every gun can be used to kill at most one monster, and obviously every monster can be killed at most once.

Xuejiejie wants to gain most of the bonus. It's no need for her to kill all monsters.

Input

In the first line there is an integer T, indicates the number of test cases.

In each case:

The first line contains two integers n, m.

The second line contains n integers, which means every gun's attack power.

The third line contains m integers, which mean every monster's defensive power.

1≤n,m≤100000, −109≤a[i],b[j]≤109。

Output

For each test case, output one integer which means the maximum of the bonus Xuejiejie could gain.

Sample Input

1

2 2

2 3

Sample Output

Source

<a target="_blank" href="http://acm.hdu.edu.cn/search.php?field=problem&amp;key=BestCoder+Round+%2347+%28%24%29&amp;source=1&amp;searchmode=source">BestCoder Round #47 ($)</a>

题意:

本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5176723.html,如需转载请自行联系原作者