思路

贪心:先把a[i]-b[i]的绝对值存入优先队列,在一 一取出最大值,每次把top元素减一,再把结果的绝对值存入队列。直到操作次数用完,在统计一下结果就好了。

代码

#include <cstring>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
int n,k1,k2;
const int N=1e3+5;
ll a[N],b[N];
priority_queue<ll> q;
int main(){cin >> n >> k1 >> k2;int sum=k1+k2;for(int i=0;i<n;i++){cin >> a[i];}for(int i=0;i<n;i++){cin >> b[i];}for(int i=0;i<n;i++){q.push(abs(a[i]-b[i]));}while(sum--){ll t=q.top();q.pop();t--;q.push(abs(t));}ll ans=0;while(q.size()){ll t=q.top();q.pop();ans+=t*t;}cout << ans;
}

Minimize the error相关推荐

  1. 19 Error handling and Go go语言错误处理

    Error handling and Go go语言错误处理 12 July 2011 Introduction If you have written any Go code you have pr ...

  2. webapck运行报错- css-loader minimize

    在使用css-loader的minimize时报错: ERROR in ./index.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].r ...

  3. 基于DQN强化学习训练一个超级玛丽

    点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 Author:MyEncyclopedia From:MyEncy ...

  4. 棋盘格检测--Automatic camera and range sensor calibration using a single shot

    Automatic camera and range sensor calibration using a single shot Robotics and Automation (ICRA), IE ...

  5. 基于TensorFlow理解三大降维技术:PCA、t-SNE 和自编码器

    ythonista 数据科学家 Elior Cohen 近日在 Medium 上发文解读了最常见的三大降维技术:PCA.t-SNE 和自编码器.为了帮助理解,他还为其中每种相关算法编写了代码(也发布在 ...

  6. 资源推荐 | TensorFlow电子书《FIRST CONTACT WITH TENSORFLOW》

    资源推荐 | TensorFlow电子书<FIRST CONTACT WITH TENSORFLOW> 2016-06-29 系统科学社 本书由 UPC Barcelona Tech大学教 ...

  7. 李宏毅深度学习——Tips for Deep Learning

    目录 一.神经网络的表现 二.改进神经网络 (一)梯度消失以及改进办法 (二)Adaptive Learning Rate (三)Local minimize问题 三.解决overfitting (一 ...

  8. Matlab神经网络十讲(7): Adaptive Filter and Adaptive Training

    1. Adaptive Function The function adapt can change the weight and bias of a network incrementally du ...

  9. 机器人学习--Hans Moravec在斯坦福博士论文1980年-Obstacle Avoidance and Navigation in the Real World by a Seeing Ro

    Hans Moravec,占用栅格地图的发明人. Obstacle Avoidance and Navigation in the Real World by a Seeing Robot Rover ...

最新文章

  1. DFA在C#中的实现:过滤敏感词
  2. js、PHP将分数字符串转换为小数
  3. HDUOJ-----Brave Game
  4. 编程php分析器,如何编程访问分析器数据
  5. jboss默认进程名称_快速指南:剖析JBoss BPM跨进程通信
  6. case mybatis 不同表_解决mybatis case when 报错的问题
  7. python装饰器class_PYTHON里的装饰器能装饰类吗
  8. Tomcat详解(四)——Tomcat配置详解
  9. sqlmap批量扫描burpsuite拦截的日志记录
  10. .net5项目托管到iis无法访问
  11. r2d 小米路由器2_维修一台亮黄灯的R2D小米路由器2
  12. android qq分享纯图片,手机照片批量上传QQ空间一键分享省流量
  13. DOM及DOM二级事件
  14. 资深运维也不知道的那些事
  15. UE4材质初探(转载)
  16. 南卫理公会大学计算机科学,南卫理公会大学计算机科学专业.pdf
  17. Cesium 源码解析 Model(一)
  18. 55 非谓语动词语法
  19. 能ping通ip却不能ping通域名
  20. 史上最易懂——一文详解线性回归算法的纯Python实现

热门文章

  1. Solidity的delete操作
  2. matlab中repmat()函数解释
  3. PMP之考试技巧总结
  4. Amazon live亚马逊直播选品建议
  5. java jdk的安装路径_jdk的默认安装路径是什么
  6. 听性脑干反应类毕业论文文献有哪些?
  7. Address already in use: bind
  8. 手工编写QTP测试脚本
  9. 加密潮流:时尚向元宇宙的进阶
  10. 怎样把智能桌牌的价格降下来 ――电子墨水屏桌牌的精简降本设计