305067: CF960B. Minimize the error
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Minimize the error
题意翻译
有两个长度均为 $n$ 的序列 $a,b$,定义 ${\rm cost}(a,b)$ : $$ {\rm cost}(a,b)=\sum_{i=1}^{n}\left(a_{i}-b_{i}\right)^{2} $$ 现在必须**恰好**对 $a$ 进行 $k_1$ 次操作,对 $b$ 进行 $k_2$ 次操作。操作内容是将某一项加一或者减一。求操作后的最小 $\rm cost$。 translated by @皎月半洒花。题目描述
You are given two arrays $ A $ and $ B $ , each of size $ n $ . The error, $ E $ , between these two arrays is defined ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960B/e950d33ee993b9f2e2ad61182c68b371192cc68e.png). You have to perform exactly $ k_{1} $ operations on array $ A $ and exactly $ k_{2} $ operations on array $ B $ . In one operation, you have to choose one element of the array and increase or decrease it by $ 1 $ . Output the minimum possible value of error after $ k_{1} $ operations on array $ A $ and $ k_{2} $ operations on array $ B $ have been performed.输入输出格式
输入格式
The first line contains three space-separated integers $ n $ ( $ 1<=n<=10^{3} $ ), $ k_{1} $ and $ k_{2} $ ( $ 0<=k_{1}+k_{2}<=10^{3} $ , $ k_{1} $ and $ k_{2} $ are non-negative) — size of arrays and number of operations to perform on $ A $ and $ B $ respectively. Second line contains $ n $ space separated integers $ a_{1},a_{2},...,a_{n} $ ( $ -10^{6}<=a_{i}<=10^{6} $ ) — array $ A $ . Third line contains $ n $ space separated integers $ b_{1},b_{2},...,b_{n} $ ( $ -10^{6}<=b_{i}<=10^{6} $ )— array $ B $ .
输出格式
Output a single integer — the minimum possible value of ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF960B/52c5522faff1ae1553e7476d3c27b93932998da8.png) after doing exactly $ k_{1} $ operations on array $ A $ and exactly $ k_{2} $ operations on array $ B $ .
输入输出样例
输入样例 #1
2 0 0
1 2
2 3
输出样例 #1
2
输入样例 #2
2 1 0
1 2
2 2
输出样例 #2
0
输入样例 #3
2 5 7
3 4
14 4
输出样例 #3
1