洛谷 P1048 采药
2024-08-30 07:49:22
采药
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;
}
最新文章
- dubox首次调用消费者执行两次问题
- 【BZOJ1002】[FJOI2007]轮状病毒 递推+高精度
- Giving Data Backup Option in Oracle Forms 6i
- PXE-kickstart无人值守批量装机
- erl0009 - erlang 读取时间瓶颈解决办法
- uva 701
- Spring+MyBatis实践—MyBatis数据库访问
- java线程池分析和应用
- IOS详解TableView——对话聊天布局的实现
- Appium根据xpath获取控件实例随笔
- 深入理解Python的字符编码
- 软件测试2gkd
- Java对象、引用、实例
- java web path
- Kafka发送到分区的message是否是负载均衡的?
- NO.1 Day 计算机基础
- 日记整理---->;2016-11-01
- 【BZOJ4556】[Tjoi2016&;Heoi2016]字符串 后缀数组+二分+主席树+RMQ
- Redis 资料整理
- 国内yum源的安装(163,阿里云,epel)
热门文章
- Exceprtion:e createQuery is not valid without active transaction; nested exception is org.hibernate.HibernateException: createQuery is not valid without active transaction
- bzoj 4289 PA2012 Tax——构图
- 20.java的7种控制语句
- 下载android sdk
- httpclient:实现有验证码的模拟登陆
- 1.7 hive基本操作
- 【网络爬虫】【python】网络爬虫(二):网易微博爬虫软件开发实例(附软件源码)
- tensorflow weight_variable going
- C#利用WebService接口下载文件
- POJ2406【KMP-next数组】