题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2748

怎么会有这样的省选题...

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,st,mx,c[];
bool f[][];
int main()
{
scanf("%d%d%d",&n,&st,&mx);
for(int i=;i<=n;i++)scanf("%d",&c[i]);
f[][st]=;
for(int i=;i<=n;i++)
for(int j=;j<=mx;j++)
{
if(j+c[i]<=mx)f[i][j]|=f[i-][j+c[i]];
if(j-c[i]>=)f[i][j]|=f[i-][j-c[i]];
}
int ans=-;
for(int j=mx;j>=;j--)
if(f[n][j])
{
ans=j;break;
}
printf("%d",ans);
return ;
}

最新文章

  1. mysql概要(十三)备份和恢复
  2. topcoder 673
  3. remastersys修改默认选项
  4. java集合——进度1
  5. ionic ion-list 滑到底部自动加载数据案例
  6. 卷积神经网络(CNN)前向传播算法
  7. iOS开发之单例模式
  8. 1.0、Android Studio管理你的项目
  9. ES6的let
  10. python--第十三天总结(html ,css 语法)
  11. Newtonsoft的序列化和反序列化
  12. mysql5.7报err 1055错误 sql_mode=only_full_group_by
  13. WPF手动绑定事件
  14. 00013 - top命令详解
  15. [python] os.path模块常用方法汇总
  16. Delphi应用程序的调试(四)The Debug Inspector
  17. js中函数传参的情况
  18. I.MX6 eMMC 中启动U-boot存放的首地址
  19. 获取当前路径下的所有文件路径 :listFiles
  20. eslasticsearch操作集锦

热门文章

  1. luogu P1043 数字游戏
  2. 【Todo】ssh的原理和实践
  3. 高仿微信实现左滑显示删除button功能
  4. 走入asp.net mvc不归路:[4]说说Action有哪些常见成员
  5. 面向对象 委托变量和this的使用
  6. iOS 相似淘宝商品详情查看翻页效果的实现
  7. @SuppressWarnings 用法
  8. Mysql整数运算NULL值处理注意点
  9. Android_Service详解及实例
  10. 增加实时性的异常url检测