采药

01背包模板题。

#include <iostream>
#include <cstdio>
using namespace std;
//Mystery_Sky
//一维01背包模板
#define M 1000
int f[M], c[M], w[M];
int ans, v, m;
int main() {
scanf("%d%d", &v, &m);
for(int i = 1; i <= m; i++) scanf("%d%d", &c[i], &w[i]);
for(int i = 1; i <= m; i++)
for(int j = v; j >= c[i]; j--) {
f[j] = max(f[j], f[j-c[i]]+w[i]);
}
printf("%d\n", f[v]);
return 0;
}

最新文章

  1. dubox首次调用消费者执行两次问题
  2. 【BZOJ1002】[FJOI2007]轮状病毒 递推+高精度
  3. Giving Data Backup Option in Oracle Forms 6i
  4. PXE-kickstart无人值守批量装机
  5. erl0009 - erlang 读取时间瓶颈解决办法
  6. uva 701
  7. Spring+MyBatis实践—MyBatis数据库访问
  8. java线程池分析和应用
  9. IOS详解TableView——对话聊天布局的实现
  10. Appium根据xpath获取控件实例随笔
  11. 深入理解Python的字符编码
  12. 软件测试2gkd
  13. Java对象、引用、实例
  14. java web path
  15. Kafka发送到分区的message是否是负载均衡的?
  16. NO.1 Day 计算机基础
  17. 日记整理----&gt;2016-11-01
  18. 【BZOJ4556】[Tjoi2016&amp;Heoi2016]字符串 后缀数组+二分+主席树+RMQ
  19. Redis 资料整理
  20. 国内yum源的安装(163,阿里云,epel)

热门文章

  1. Exceprtion:e createQuery is not valid without active transaction; nested exception is org.hibernate.HibernateException: createQuery is not valid without active transaction
  2. bzoj 4289 PA2012 Tax——构图
  3. 20.java的7种控制语句
  4. 下载android sdk
  5. httpclient:实现有验证码的模拟登陆
  6. 1.7 hive基本操作
  7. 【网络爬虫】【python】网络爬虫(二):网易微博爬虫软件开发实例(附软件源码)
  8. tensorflow weight_variable going
  9. C#利用WebService接口下载文件
  10. POJ2406【KMP-next数组】