当前位置:网站首页>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;
}边栏推荐
- BiLSTM-CRF代码实现
- Mitsubishi PLC FX3U pulse axis jog function block (mc_jog)
- Global and Chinese markets for food allergens and intolerance tests 2022-2028: Research Report on technology, participants, trends, market size and share
- [JS download files through url]
- sso单点登录的实现。
- cookie、session、tooken
- 2023款雷克萨斯ES产品公布,这回进步很有感
- 股票开户哪个证券公司比较安全
- UVM tutorial
- To meet the needs of consumers in technological upgrading, Angel water purifier's competitive way of "value war"
猜你喜欢

【微信授权登录】uniapp开发小程序,实现获取微信授权登录功能

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

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

Leetcode skimming: stack and queue 01 (realizing queue with stack)

What does open loop and closed loop mean?

Weather forecast applet source code weather wechat applet source code

Keepalived introduction and installation

Mysql database driver (JDBC Driver) jar package download

SSO single sign on implementation.
随机推荐
AIX存储管理之总结篇
DTL dephossite | prediction method of dephosphorylation sites based on Transfer Learning
XMIND mind map
From 20s to 500ms, I used these three methods
Node——添加压缩文件
Node——Egg 实现上传文件接口
【八大排序③】快速排序(动图演绎Hoare法、挖坑法、前后指针法)
2022 operation of simulated examination platform for melting welding and thermal cutting work license
LeetCode 0241. Design priority for arithmetic expressions - DFS
Keepalived introduction and installation
股票开户哪个证券公司比较安全
Comprehensive broadcast of global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
JS -- image to base code, base to file object
Upgraded wechat tool applet source code for mobile phone detection - supports a variety of main traffic modes
Leetcode skimming: stack and queue 04 (delete all adjacent duplicates in the string)
[bottom pop-up selector] uniapp picker component - scroll selector popped up at the bottom
Cmake engineering related
Schrodinger's Japanese learning applet source code
Mysql database driver (JDBC Driver) jar package download
Weather forecast applet source code weather wechat applet source code