当前位置:网站首页>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;
}边栏推荐
- 【CTF】bjdctf_2020_babystack2
- King combat power query renamed toolbox applet source code - with traffic main incentive advertisement
- Cmake engineering related
- Collection: comprehensive summary of storage knowledge
- Output results of convolution operation with multiple tensors and multiple convolution kernels
- Accelerator systems initiative is an independent non-profit organization
- The new version of graphic network PDF will be released soon
- 测试人进阶技能:单元测试报告应用指南
- JS -- image to base code, base to file object
- 工作中非常重要的测试策略,你大概没注意过吧
猜你喜欢
![[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login](/img/c1/23be4399119f42d85a7b86fc8a59fc.png)
[wechat authorized login] the small program developed by uniapp realizes the function of obtaining wechat authorized login

Basis of deep learning neural network

gradle

一名优秀的软件测试人员,需要掌握哪些技能?

export default 导出的对象,不能解构问题,和module.exports的区别

How to extract login cookies when JMeter performs interface testing

【八大排序②】选择排序(选择排序,堆排序)

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

AIX存储管理之卷组属性的查看和修改(二)

Leetcode skimming: stack and queue 01 (realizing queue with stack)
随机推荐
2023 Lexus ES products have been announced, which makes great progress this time
XMIND mind map
BPR (Bayesian personalized sorting)
股票开户哪个证券公司比较安全
使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
Global and Chinese market of wireless chipsets 2022-2028: Research Report on technology, participants, trends, market size and share
[eight sorts ④] merge sort, sort not based on comparison (count sort, cardinal sort, bucket sort)
【八大排序②】选择排序(选择排序,堆排序)
程序员该如何更好的规划自己的职业发展?
Global and Chinese market of picture archiving and communication system (PACS) 2022-2028: Research Report on technology, participants, trends, market size and share
Node -- add compressed file
Intelligent operation and maintenance practice: banking business process and single transaction tracking
cookie、session、tooken
Global and Chinese market of wireless charging magnetic discs 2022-2028: Research Report on technology, participants, trends, market size and share
Bc35 & bc95 onenet mqtt (old)
Node——Egg 实现上传文件接口
"C zero foundation introduction hundred knowledge hundred examples" (73) anonymous function -- lambda expression
Use es to realize epidemic map or take out order function (including code and data)
BiLSTM-CRF代码实现
[conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)