#P7382. [COCI 2018/2019 #6] Simfonija

[COCI 2018/2019 #6] Simfonija

Description

You are given two arrays AA and BB, each containing NN elements. Add an integer XX to every element in array AA, and then modify at most KK elements, so that the following expression is minimized:

i=1NAiBi\sum_{i=1}^N |A_i-B_i|

Input Format

The first line contains integers N,KN, K.

The second line contains NN integers AiA_i.

The third line contains NN integers BiB_i.

Output Format

Output the minimum value of the expression after the operations.

3 0
1 2 3
4 5 7
1
3 1
1 2 3
4 5 7
0
4 1
1 2 1 2
5 6 7 8
2

Hint

Explanation for Sample 2

When choosing X=3X = 3 and changing the last number in array AA to 77, the two arrays AA and BB become exactly the same, so the value of the expression is 00.

Constraints

For 40%40\% of the testdata, K=0K = 0.

For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 0KN0 \le K \le N, 106Ai,Bi106-10^6 \le A_i, B_i \le 10^6.

Note

The score for this problem follows the original COCI settings, with a full score of 110110.

Translated from COCI2018-2019 CONTEST #6 T4 Simfonija.

Translated by ChatGPT 5