CF960B.Minimize the error

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two arrays AA and BB , each of size nn . The error, EE , between these two arrays is defined . You have to perform exactly k1k_{1} operations on array AA and exactly k2k_{2} operations on array BB . In one operation, you have to choose one element of the array and increase or decrease it by 11 .

Output the minimum possible value of error after k1k_{1} operations on array AA and k2k_{2} operations on array BB have been performed.

输入格式

The first line contains three space-separated integers nn ( 1<=n<=1031<=n<=10^{3} ), k1k_{1} and k2k_{2} ( 0<=k1+k2<=1030<=k_{1}+k_{2}<=10^{3} , k1k_{1} and k2k_{2} are non-negative) — size of arrays and number of operations to perform on AA and BB respectively.

Second line contains nn space separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 106<=ai<=106-10^{6}<=a_{i}<=10^{6} ) — array AA .

Third line contains nn space separated integers b1,b2,...,bnb_{1},b_{2},...,b_{n} ( 106<=bi<=106-10^{6}<=b_{i}<=10^{6} )— array BB .

输出格式

Output a single integer — the minimum possible value of after doing exactly k1k_{1} operations on array AA and exactly k2k_{2} operations on array BB .

输入输出样例

  • 输入#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

说明/提示

In the first sample case, we cannot perform any operations on AA or BB . Therefore the minimum possible error E=(12)2+(23)2=2E=(1-2)^{2}+(2-3)^{2}=2 .

In the second sample case, we are required to perform exactly one operation on AA . In order to minimize error, we increment the first element of AA by 11 . Now, A=[2,2]A=[2,2] . The error is now E=(22)2+(22)2=0E=(2-2)^{2}+(2-2)^{2}=0 . This is the minimum possible error obtainable.

In the third sample case, we can increase the first element of AA to 88 , using the all of the 55 moves available to us. Also, the first element of BB can be reduced to 88 using the 66 of the 77 available moves. Now A=[8,4]A=[8,4] and B=[8,4]B=[8,4] . The error is now E=(88)2+(44)2=0E=(8-8)^{2}+(4-4)^{2}=0 , but we are still left with 11 move for array BB . Increasing the second element of BB to 55 using the left move, we get B=[8,5]B=[8,5] and E=(88)2+(45)2=1E=(8-8)^{2}+(4-5)^{2}=1 .

首页