当前位置:网站首页>Minimize the error
Minimize the error
2022-07-02 00:56:00 【Learning KL & TK】
Problem - B - Codeforces
https://codeforces.com/contest/960/problem/B The title means to give you The length is n , a Array k1 operations ,b Array k2 operations
Each operation can +1 or -1
Their thinking
Put every a and b The pairing value of is calculated first , The question should be the square of the absolute value , Because we need to make the answer smaller , Reducing the large absolute value can make the final total result smaller , Then priority queue can be used to solve this problem
#include"bits/stdc++.h"
#define ll long long
#define pi pair<int,int>
#define inf 0x3f3f3f3f
#define _for(i,a,b) for(int i=a;i<=b;i++)
#define for_(i,a,b) for(int i=a;i<b;i++)
#define _fr(i,a,b) for(int i=a;i>=b;i--)
#define fr_(i,a,b) for(int i=a;i>b;i--)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
const int N = 1e3+5;
const ll mod = 1e9+7;
const double lp=1.000000011;
map<char,int>mp;
int n,m,d,t;
priority_queue<ll,vector<ll>,less<ll>>q;
void solve(){
int k1,k2;
cin >> n >> k1 >> k2;
vector<int>a(n),b(n),c(n);
for_(i,0,n) cin >> a[i];
for_(i,0,n){
cin >> b[i];
c[i]= abs(a[i]-b[i]);
q.push(c[i]);
}
int ans = k1+k2;
while (ans--){
int lo = q.top();
q.pop();
q.push(abs(lo-1));
}
ll sum = 0;
while (!q.empty()){
sum+=q.top()*q.top();
q.pop();
}
cout << sum << endl;
}
int main()
{
IOS;
solve();
return 0;
}边栏推荐
- Advanced skills of testers: a guide to the application of unit test reports
- Mitsubishi PLC FX3U pulse axis jog function block (mc_jog)
- Zak's latest "neural information transmission", with slides and videos
- 使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
- Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education
- Leetcode skimming: binary tree 03 (post order traversal of binary tree)
- @Valid参数校验不生效
- [wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login
- JS -- image to base code, base to file object
- export default 导出的对象,不能解构问题,和module.exports的区别
猜你喜欢

Basis of deep learning neural network

Use es to realize epidemic map or take out order function (including code and data)

2022 safety officer-b certificate examination practice questions simulated examination platform operation

"C zero foundation introduction hundred knowledge hundred examples" (73) anonymous function -- lambda expression

What is ThreadLocal memory leak and how to solve it

Friends circle community program source code sharing

How to type spaces in latex

Barbie q! How to analyze the new game app?

Promise和模块块化编程
![[bottom pop-up selector] uniapp picker component - scroll selector popped up at the bottom](/img/d4/9d27b29080ce83004aa875a499de9b.png)
[bottom pop-up selector] uniapp picker component - scroll selector popped up at the bottom
随机推荐
Leetcode skimming: stack and queue 06 (top k high-frequency elements)
Viewing and modifying volume group attributes of Aix storage management (II)
【CTF】bjdctf_2020_babystack2
Export default the exported object cannot be deconstructed, and module Differences between exports
【opencv】train&test HOG+SVM
Basis of deep learning neural network
SSO single sign on implementation.
Global and Chinese markets for freight and logistics 2022-2028: Research Report on technology, participants, trends, market size and share
DTL dephossite | prediction method of dephosphorylation sites based on Transfer Learning
AIX存储管理之卷组的创建(一)
JS -- image to base code, base to file object
Cmake engineering related
Node——添加压缩文件
Entrepreneurship is a little risky. Read the data and do a business analysis
Node——Egg 创建本地文件访问接口
2022 low voltage electrician examination questions and answers
The new version of graphic network PDF will be released soon
Leetcode skimming: binary tree 03 (post order traversal of binary tree)
AIX存储管理之总结篇
What skills does an excellent software tester need to master?