洛谷P1048采药题解
2024-10-10 22:10:13
这是一个裸的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]; }
最新文章
- cobbler安装、部署、测试
- TCP服务器不回复SYN的问题
- 最常用的javascript方法函数
- (转载)OC学习篇之---类的定义
- javascript中强制类型转换
- Android bitmap序列化
- HTTPS的学习
- MyBatis学习总结——实现关联表查询(转)
- PPT分享 | 怎么在区块链上保护隐私?
- ValueError: setting an array element with a sequence.
- JDK源码分析(8)之 Reference 完全解读
- tensorflow入门指南
- ELF分析 实践
- Android MediaPlayer架构 -- 前言小知识点(二)
- SIGTERM、SIGKILL、SIGINT和SIGQUIT的区别
- python 3.6.5 sys模块和os模块
- java8 - 多线程时间安全问题
- MFC+WinPcap编写一个嗅探器之七(协议)
- C# 使用dynamic类型来访问JObject对象
- 【BZOJ】1653: [Usaco2006 Feb]Backward Digit Sums(暴力)
热门文章
- Python股票分析系列——系列介绍和获取股票数据.p1
- Python-TXT文本操作
- H5 28-优先级之权重问题
- 小P的字符串
- .call() 和 .apply() 的含义和区别
- hibernate异常找不到get方法org.hibernate.PropertyNotFoundException: Could not find a getter for did in class com.javakc.hibernate.manytomany.entity.CourseEntity
- IBM的淘汰之路
- MySQL复制表的方式以及原理和流程
- 安装pandas时出现环境错误
- JS_左边栏菜单