F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Senior's Gun

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 4255    Accepted Submission(s): 1338


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]\leq 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\leq n, m\leq 100000$, $-10^9 \leq a[i], b[j]\leq 10^9$ĄŁ
 

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 2 2
 

Sample Output
1
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-09 16:39:53, Gzip enabled