题目描述:https://pycoder.blog.csdn.net/article/details/125270003?spm=1001.2014.3001.5502

动态规划 : dp[i] 表示是否能组成容量为 i 的战斗力。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>int main(void) {int arr[10] = {0};int sum = 0;int target;bool dp[50000] = {0};int max = 0;for (int i = 0; i < 10; i++) {scanf("%d", &arr[i]);sum += arr[i];}target = sum / 2;dp[0] = true;for (int i = 0; i < 10; i++) {for (int j = target; j > 0; j--) {  // 如果是从小到大的话,会存在重复计算球员战斗力的情况int pre = j - arr[i];if (pre >= 0) {dp[j] = dp[j] || dp[pre];}if (dp[j]) {max = fmax(max, j);}}}printf("%d\n", abs((sum - max) - max));return 0;
}

华为机试C语言-篮球比赛相关推荐

  1. 华为机试C语言-最远足迹

    题目描述:https://pycoder.blog.csdn.net/article/details/125531902 https://blog.csdn.net/weixin_44052055/a ...

  2. 华为机试C语言-找到比自己强的人数

    题目描述:https://pycoder.blog.csdn.net/article/details/127216746?spm=1001.2014.3001.5502 https://blog.cs ...

  3. 华为机试C语言-服务失效判断

    题目描述:https://zhuanlan.zhihu.com/p/526678876 https://blog.csdn.net/weixin_39765576/article/details/12 ...

  4. 华为机试C语言-VLAN资源池

    题目描述:https://pycoder.blog.csdn.net/article/details/125175834 #include <stdio.h> #include <s ...

  5. 华为机试C语言-整形数组按个位值排序

    题目描述:https://pycoder.blog.csdn.net/article/details/124600540 #include <stdio.h> #include <s ...

  6. 华为机试C语言-组成最大数

    题目描述:https://pycoder.blog.csdn.net/article/details/125923027 想不到这也是一道qsort的题目~ #include <stdio.h& ...

  7. 华为机试C语言-Words重量

    题目描述:https://pycoder.blog.csdn.net/article/details/124743820 #include <stdio.h> #include <s ...

  8. 华为机试C语言-一个正整数到Excel编号之间的转换

    题目描述:https://blog.csdn.net/qq_23934063/article/details/124676929 #include <stdio.h> #include & ...

  9. 华为机试C语言-欢乐的周末

    题目描述:https://pycoder.blog.csdn.net/article/details/125401136 递归,回溯的时候要考虑周全,不然白理解了. #include <stdi ...

最新文章

  1. Kmeans算法的过程是什么?Kmeans算法的缺陷主要有哪些?
  2. 雅虎书面问题——最大的问题汇总
  3. 计算机组成名词解释移码,自考“计算机组成原理”串讲资料
  4. salesforce零基础学习(八十九)使用 input type=file 以及RemoteAction方式上传附件
  5. “约见”面试官系列之常见面试题之第六十八篇之本地对象 内置对象 宿主对象(建议收藏)
  6. 深入探讨C++中的引用
  7. 关于Ajax的get与post浅分析,同步请求与异步请求,跨域请求;
  8. Ant-design-vue定制主题色
  9. 计算机网络管理人员理论A卷,2011年上半年计算机网络管理员(三级)理论鉴定试题A...
  10. HTTP 连接管理进化论
  11. 兼容最好的设为首页加入收藏代码
  12. 你了解实时3D渲染吗?实时渲染软件和应用场景科普来了
  13. 安装AdventureWorks2008R2示例数据库
  14. 08cms cecore.cls.php,08CMS 变量覆盖导致getshell 等问题
  15. Ruby on Rails 教程
  16. 升级openssh后出现问题(kex_exchange_identification: client sent。。。。。)
  17. 计算机一级比分多少,如何在电子表格中打出比分?
  18. Javascript代码优化的8个知识点 1
  19. 微信小程序---轮播图
  20. Linux查看进程 ps aux指令详解

热门文章

  1. RTT之创建动态线程
  2. 互联网行业的鄙视链之装逼与反装逼
  3. 【出行】查看哈啰出行顺风车司机自己的评分,信任分
  4. 文秘工作计算机水平,文秘办公必须掌握的电脑技巧
  5. 利用C语言实现sin(x)曲线与cos(x)曲线图形的同时显示
  6. 计算机语言赋值号,赋值
  7. Shiro集成Spring框架并且多Realms报错No realms have been configured! One or more realms must be ……解决办法
  8. 金融科技之情感分析:股民情绪指数与股市价格的相关性分析
  9. NOIP200703守望者的逃离 题解
  10. 我的心是冰冰的,但老婆是新垣结衣!