Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define vi vector<int>
- #define ll long long
- #define pb push_back
- #define mp make_pair
- #define ii pair<int,int>
- #define NDEBUG
- #include <assert.h>
- int main(){
- int n,k1,k2;
- int aux;
- priority_queue<ii> diferencas;
- vector<int> A,B;
- scanf("%d %d %d",&n,&k1,&k2);
- for (int i = 0; i < n; ++i)
- {
- scanf("%d",&aux);
- A.pb(aux);
- }
- for (int i = 0; i < n; ++i)
- {
- scanf("%d",&aux);
- B.pb(aux);
- if(A[i] > aux){
- diferencas.push(mp((A[i] - aux),i));
- }else{
- diferencas.push(mp((aux - A[i]),i));
- }
- }
- ii base = diferencas.top();
- ii it;
- int m = k1+k2;
- int j = 0;
- while(m > 0)
- {
- it = diferencas.top();
- if(it.first >= base.first){
- if (A[j] > B[j])
- {
- it.first--;
- }else{
- if ((A[j] - B[j]) < 0)
- {
- it.first--;
- }else{
- it.first++;
- }
- }
- m--;
- diferencas.push(it);
- }
- diferencas.pop();
- base = diferencas.top();
- //printf("nova base %d\n", base.first);
- }
- m = diferencas.size();
- int sum = 0;
- for (int i = 0; i < m; ++i)
- {
- it = diferencas.top();
- sum += (it.first)*(it.first);
- diferencas.pop();
- }
- printf("%d\n", sum);
- return 0;
- }
- /*
- compilar
- g++ arquivo.cpp -std=c++11 -o executavel
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement