2414 Please help the poor donkey!
Time Limit : 2000/1000 MS(Java/Others) | Memory Limit : 131072/65536 KB(Java/Others)
Submits : 6 | Solved : 1
Description
A donkey is on his way home with many goods hanging on the two side of his back ,tired and thirsty . What a poor donkey ! What's worse , the total weight of the goods on each side of his back doesn't have the same value , which makes the poor donkey much more difficult to keep balance .Now I should to help the poor donkey move some goods from one side to another to ease his burden . I want to minimize the difference of the total weight between the two sides .Of course I'm very lazy ,could you tell me the minimum number of the goods that I need to move to minimize the difference of the total weight betwoon the two sides. If you tell me the correct answer , I will give you an 'AC' !
Input
Input contains multiple test cases. The first line of each test cases contains two integers n and m , n indicates the number of the goods hanging on the left side of the donkey, m indicates the number of the goods hanging on the right side of the donkey.(0<n+m<=1000)
The second line of the test case contains n integers indicating the weight of the n goods on the left side .
The third line contains m integers indicating the weight of the m goods on the right .
Output
Output the minimum number of the goods that I need to move .
Sample Input
1 3
5
4 2 1
Sample Output
1
HINT
Source
NBU
[ Top ] | [ Submit ]