题目

这是一个裸的01背包,因为题目中没说可以采好多次,不多说上代码,

#include<iostream>
using namespace std;
int main()
{
  int n,m,v,i;
  int c[10000],w[10000],f[10000];
  cin>>m>>n;
  for( i=1;i<=n;i++)
    cin>>w[i]>>c[i];
    for( i=1;i<=n;i++)
      for( v=m;v>=w[i];v--)
        if(f[v-w[i]]+c[i]>f[v])
        f[v]=f[v-w[i]]+c[i];
        cout<<f[m];
}

  

最新文章

  1. cobbler安装、部署、测试
  2. TCP服务器不回复SYN的问题
  3. 最常用的javascript方法函数
  4. (转载)OC学习篇之---类的定义
  5. javascript中强制类型转换
  6. Android bitmap序列化
  7. HTTPS的学习
  8. MyBatis学习总结——实现关联表查询(转)
  9. PPT分享 | 怎么在区块链上保护隐私?
  10. ValueError: setting an array element with a sequence.
  11. JDK源码分析(8)之 Reference 完全解读
  12. tensorflow入门指南
  13. ELF分析 实践
  14. Android MediaPlayer架构 -- 前言小知识点(二)
  15. SIGTERM、SIGKILL、SIGINT和SIGQUIT的区别
  16. python 3.6.5 sys模块和os模块
  17. java8 - 多线程时间安全问题
  18. MFC+WinPcap编写一个嗅探器之七(协议)
  19. C# 使用dynamic类型来访问JObject对象
  20. 【BZOJ】1653: [Usaco2006 Feb]Backward Digit Sums(暴力)

热门文章

  1. Python股票分析系列——系列介绍和获取股票数据.p1
  2. Python-TXT文本操作
  3. H5 28-优先级之权重问题
  4. 小P的字符串
  5. .call() 和 .apply() 的含义和区别
  6. hibernate异常找不到get方法org.hibernate.PropertyNotFoundException: Could not find a getter for did in class com.javakc.hibernate.manytomany.entity.CourseEntity
  7. IBM的淘汰之路
  8. MySQL复制表的方式以及原理和流程
  9. 安装pandas时出现环境错误
  10. JS_左边栏菜单