当前位置:网站首页>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;
}边栏推荐
- Picture puzzle wechat applet source code_ Support multi template production and traffic master
- Global and Chinese markets for food allergens and intolerance tests 2022-2028: Research Report on technology, participants, trends, market size and share
- JMeter做接口测试,如何提取登录Cookie
- [opencv450] hog+svm and hog+cascade for pedestrian detection
- XMind思维导图
- BPR (Bayesian personalized sorting)
- How can programmers better plan their career development?
- 2023款雷克萨斯ES产品公布,这回进步很有感
- Global and Chinese markets for distributed generation and energy storage in telecommunications networks 2022-2028: Research Report on technology, participants, trends, market size and share
- LeetCode 0241.为运算表达式设计优先级 - DFS
猜你喜欢

The new version of graphic network PDF will be released soon

To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"

测试人进阶技能:单元测试报告应用指南

Advanced skills of testers: a guide to the application of unit test reports

Creating logical volumes and viewing and modifying attributes for AIX storage management

AIX存储管理之卷组的创建(一)

Common loss function of deep learning

Leetcode skimming: binary tree 01 (preorder traversal of binary tree)

SSO single sign on implementation.

You probably haven't noticed the very important testing strategy in your work
随机推荐
Friends circle community program source code sharing
Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education
AIX存储管理之逻辑卷的创建及属性的查看和修改
AIX存储管理之总结篇
Schrodinger's Japanese learning applet source code
S32Kxxx bootloader之UDS bootloader
Xinniuniu blind box wechat applet source code_ Support flow realization, with complete material pictures
Node——添加压缩文件
The 8-year salary change of testers makes netizens envy it: you pay me one year's salary per month
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
Source code of Qiwei automatic card issuing system
449-原码、补码、反码
【八大排序③】快速排序(动图演绎Hoare法、挖坑法、前后指针法)
How to reflect and solve the problem of bird flight? Why are planes afraid of birds?
Leetcode skimming: binary tree 03 (post order traversal of binary tree)
工作中非常重要的测试策略,你大概没注意过吧
Mysql database driver (JDBC Driver) jar package download
Creating logical volumes and viewing and modifying attributes for AIX storage management
Global and Chinese markets for context and location-based services 2022-2028: Research Report on technology, participants, trends, market size and share