当前位置:网站首页>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;
}边栏推荐
- excel数据透视表
- 工作中非常重要的测试策略,你大概没注意过吧
- Leetcode skimming: binary tree 01 (preorder traversal of binary tree)
- Basis of deep learning neural network
- Schrodinger's Japanese learning applet source code
- 程序员该如何更好的规划自己的职业发展?
- Talents come from afar, and Wangcheng district has consolidated the intellectual base of "strengthening the provincial capital"
- Global and Chinese markets for supply chain strategy and operation consulting 2022-2028: Research Report on technology, participants, trends, market size and share
- Collection: comprehensive summary of storage knowledge
- Picture puzzle wechat applet source code_ Support multi template production and traffic master
猜你喜欢

You probably haven't noticed the very important testing strategy in your work

【八大排序①】插入排序(直接插入排序、希尔排序)

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

Collection: comprehensive summary of storage knowledge

What is ThreadLocal memory leak and how to solve it

Barbie q! How to analyze the new game app?

JMeter做接口测试,如何提取登录Cookie

Source code of Qiwei automatic card issuing system

AIX存储管理之逻辑卷的创建及属性的查看和修改

Synthetic watermelon game wechat applet source code / wechat game applet source code
随机推荐
[leetcode] number of maximum consecutive ones
cookie、session、tooken
UVM tutorial
什么是商业养老保险?商业养老保险安全靠谱吗?
Global and Chinese markets for context and location-based services 2022-2028: Research Report on technology, participants, trends, market size and share
Node -- egg creates a local file access interface
[JS download files through url]
Otaku wallpaper Daquan wechat applet source code - with dynamic wallpaper to support a variety of traffic owners
Global and Chinese markets for food allergens and intolerance tests 2022-2028: Research Report on technology, participants, trends, market size and share
Viewing and modifying volume group attributes of Aix storage management (II)
2023款雷克萨斯ES产品公布,这回进步很有感
【opencv】train&test HOG+SVM
Node——Egg 创建本地文件访问接口
Entrepreneurship is a little risky. Read the data and do a business analysis
Some understandings of graph convolution neural network r-gcn considering relations and some explanations of DGL official code
Tensorflow tensor convolution, input and convolution kernel dimension understanding
BPR (Bayesian personalized sorting)
Cmake engineering related
[conference resources] the Third International Conference on Automation Science and Engineering in 2022 (jcase 2022)
Node——生成微信权限验证配置