好像是完全背包吧分不清了……
好像是把数组二维压一维的时候,01背包倒序,完全背包正序
```cpp

include

include

using namespace std;
const int N=105,H=55005;
int n,h,p[N],c[N],f[H];
int main()
{
scanf("%d%d",&n,&h);
for(int i=1;i<=n;i++)
scanf("%d%d",&p[i],&c[i]);
for(int i=1;i<=h+5000;i++)
f[i]=1e9;
for(int i=1;i<=n;i++)
for(int j=p[i];j<=h+5000;j++)
f[j]=min(f[j],f[j-p[i]]+c[i]);
int ans=1e9;
for(int i=h;i<=h+5000;i++)
ans=min(ans,f[i]);
printf("%d\n",ans);
return 0;
}
···

bzoj 1618: [Usaco2008 Nov]Buying Hay 购买干草【背包】的更多相关文章

  1. BZOJ 1618: [Usaco2008 Nov]Buying Hay 购买干草( dp )

    无限背包dp.. 因为题目中说至少到 H 磅 , 我就直接把 H * 2 了.. ----------------------------------------------------------- ...

  2. BZOJ 1618: [Usaco2008 Nov]Buying Hay 购买干草

    题目 1618: [Usaco2008 Nov]Buying Hay 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 679  Solved:  ...

  3. 【BZOJ】1618: [Usaco2008 Nov]Buying Hay 购买干草(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1618 裸的01背包,注意背包的容量不是v即可. #include <cstdio> #i ...

  4. [Usaco2008 Nov]Buying Hay 购买干草[背包]

    Description     约翰的干草库存已经告罄,他打算为奶牛们采购日(1≤日≤50000)磅干草.     他知道N(1≤N≤100)个干草公司,现在用1到N给它们编号.第i个公司卖的干草包重 ...

  5. [BZOJ1618][Usaco2008 Nov]Buying Hay 购买干草

    [BZOJ1618][Usaco2008 Nov]Buying Hay 购买干草 试题描述 约翰的干草库存已经告罄,他打算为奶牛们采购H(1≤H≤50000)磅干草. 他知道N(1≤N≤100)个干草 ...

  6. [Usaco2008 Nov]Buying Hay 购买干草

    题目描述 约翰的干草库存已经告罄,他打算为奶牛们采购H(1≤H≤50000)磅干草,他知道N(1≤N≤100)个干草公司,现在用1到N给它们编号.第i个公司卖的干草包重量为Pi(1≤Pi≤5000)磅 ...

  7. BZOJ 1229: [USACO2008 Nov]toy 玩具

    BZOJ 1229: [USACO2008 Nov]toy 玩具 标签(空格分隔): OI-BZOJ OI-三分 OI-双端队列 OI-贪心 Time Limit: 10 Sec Memory Lim ...

  8. bzoj1618 / P2918 [USACO08NOV]买干草Buying Hay(完全背包)

    P2918 [USACO08NOV]买干草Buying Hay 显然的完全背包 设$f[i]$为买$i$磅干草的最小代价 搞搞完全背包即可 注意到最后可能买的干草超出范围,但是价格可能更低. 于是我们 ...

  9. BZOJ 1620: [Usaco2008 Nov]Time Management 时间管理( 二分答案 )

    二分一下答案就好了... --------------------------------------------------------------------------------------- ...

随机推荐

  1. ZOJ 2561 Order-Preserving Codes

    Order-Preserving Codes Time Limit: 5000ms Memory Limit: 65536KB This problem will be judged on ZJU. ...

  2. JavaEE JDBC 核心API

    JDBC接口核心的API @author ixenos java.sql.*   和  javax.sql.* |- Driver接口: 表示java驱动程序接口.所有的具体的数据库厂商要来实现此接口 ...

  3. 如何把DEBIAN变成UBUNTU-DESKTOP最少化安装

    Ubuntu 18.04没有32位,老电脑要装32位下面方法可以实现 Debian 9.6变成Ubuntu-Desktop 最少化 1 安装Debian 9.6时用expert mode 安装,安装过 ...

  4. codeforces 330b

    #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 1100 int map[N]; ...

  5. msp430入门学习06

    msp430的IO端口的第一功能 msp430入门学习

  6. QQ - Linux中文Wiki

    QQ:http://linux-wiki.cn/wiki/zh-hans/QQ 此页由张凯于2013年7月7日 (星期日) 14:00的最后更改. 在陈泓旭和沧之声和Linux Wiki用户Chenx ...

  7. Count Color POJ - 2777 线段树

    Chosen Problem Solving and Program design as an optional course, you are required to solve all kinds ...

  8. bzoj——3555: [Ctsc2014]企鹅QQ

    3555: [Ctsc2014]企鹅QQ Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 2617  Solved: 921[Submit][Statu ...

  9. Ubuntu 16.04安装UML工具StarUML 2

    StarUML 2是一个商业软件,但是没有时间限制,就像Sublime Text 3一样.而且具有跨平台,支持Mac.Windows. 这个软件曾经08年的时候在老D的博客上有推荐过,参考:http: ...

  10. Ubuntu 16.04安装QtCharts时报错:'qtConfig' is not a recognized test function.

    错误: 'qtConfig' is not a recognized test function. 解决方法: 其实5.9分支的版本有问题,转成5.7分支即可. git clone https://g ...