One day, "Soo2 Taghezya" team was at ACPC 2025. Fady got lost because the hotel was very large, so he asked Baraa for directions to return to his team. Baraa decided to help him by giving him a problem.
He gave him an odd integer $$$N$$$ and $$$N$$$ integers $$$H_1,H_2,\dots,H_N$$$, and also $$$M$$$ integers $$$W_1,W_2,\dots,W_M$$$.
Fady must choose exactly one integer $$$W_k$$$ and add it to the multiset $$${H_1,H_2,\dots,H_N}$$$, obtaining $$$N+1$$$ integers. Then, he must partition these $$$N+1$$$ integers into exactly $$$(N+1)/2$$$ disjoint unordered pairs $$$(x_i,y_i)$$$.
The cost of a pair $$$(x_i,y_i)$$$ is $$$|x_i-y_i|$$$, and the total cost is $$$\sum_{i=1}^{(N+1)/2}|x_i-y_i|$$$. Help Fady choose $$$W_k$$$ and form the pairs so that the total cost is minimized.
The first line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \le N, M \le 2 \times 10^5$$$).
The second line contains $$$N$$$ integers $$$H_1, H_2, \dots, H_N$$$ ($$$1 \le H_i \le 10^9$$$).
The third line contains $$$M$$$ integers $$$W_1, W_2, \dots, W_M$$$ ($$$1 \le W_i \le 10^9$$$).
Print a single integer, the minimum possible total cost.
3 2 1 5 10 6 12
6
| Name |
|---|


