德夫和他的兄弟非常相爱。由于他们是超级极客,他们只喜欢玩阵列。他们的父亲给了他们两个数组a和b。数组a给了Devu,数组b给了他的兄弟。
因为Devu真的是一个淘气的孩子,他希望他的数组a的最小值至少和他兄弟的数组b的最大值一样多。
现在你必须帮助Devu达到这个条件。您可以对阵列执行多个操作。在一次操作中,允许将任意数组的任何元素减少或增加1。请注意,允许对数组的任何索引多次应用该操作。
你需要找到满足Devu条件所需的最少操作次数,这样兄弟们就可以在没有战斗的情况下和平玩耍。
Devu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother.
As Devu is really a naughty kid, he wants the minimum value of his array a should be at least as much as the maximum value of his brother's array b.
Now you have to help Devu in achieving this condition. You can perform multiple operations on the arrays. In a single operation, you are allowed to decrease or increase any element of any of the arrays by 1. Note that you are allowed to apply the operation on any index of the array multiple times.
You need to find minimum number of operations required to satisfy Devu's condition so that the brothers can play peacefully without fighting.
2 2 2 3 3 5
3
3 2 1 2 3 3 4
4
3 2 4 5 6 1 2
0
2 2 2 3 3 5
3
3 2 1 2 3 3 4
4
3 2 4 5 6 1 2
0
解释
2 2
2 3
3 5
3