bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*
bzoj3384[Usaco2004 Nov]Apple Catching 接苹果
bzoj1750[Usaco2005 qua]Apple Catching
题意:
两棵树,每分钟会从其中一棵树上掉一个苹果下来,捡苹果的人只愿意W次,问初始在树1处最多能捡多少苹果。分钟数≤1000,W≤30。
题解:
dp。f[i][j][0/1]表示第i分钟移动了j次现在在第2/1棵树下。具体看代码。
代码:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define inc(i,j,k) for(int i=j;i<=k;i++)
#define maxn 1010
#define INF 0x3fffffff
using namespace std; inline int read(){
char ch=getchar(); int f=,x=;
while(ch<''||ch>''){if(ch=='-')f=-; ch=getchar();}
while(ch>=''&&ch<='')x=x*+ch-'',ch=getchar();
return f*x;
}
bool a[maxn]; int f[][][],n,w,x,y,ans;
int main(){
n=read(); w=read(); inc(i,,n)a[i]=read()&; x=; y=;
inc(i,,w)f[x][i][]=; inc(i,,w)f[x][i][]=; f[x][][]=-INF;
inc(i,,n+){
if(!a[i-])f[y][][]=f[x][][]+,f[y][][]=f[x][][];
else f[y][][]=f[x][][],f[y][][]=f[x][][]+;
inc(j,,w){
if(!a[i-])f[y][j][]=max(f[x][j-][],f[x][j][]+),
f[y][j][]=max(f[x][j-][]+,f[x][j][]);
else f[y][j][]=max(f[x][j-][]+,f[x][j][]),
f[y][j][]=max(f[x][j-][],f[x][j][]+);
}
swap(x,y);
}
inc(i,,w)ans=max(ans,max(f[x][i][],f[x][i][])); printf("%d",ans); return ;
}
20161017
bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*的更多相关文章
- bzoj1750 [Usaco2005 qua]Apple Catching
Description It is a little known fact that cows love apples. Farmer John has two apple trees (which ...
- BZOJ 3384: [Usaco2004 Nov]Apple Catching 接苹果( dp )
dp dp( x , k ) = max( dp( x - 1 , k - 1 ) + *** , dp( x - 1 , k ) + *** ) *** = 0 or 1 ,根据情况 (BZOJ 1 ...
- 3384/1750: [Usaco2004 Nov]Apple Catching 接苹果
3384/1750: [Usaco2004 Nov]Apple Catching 接苹果 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 18 Solv ...
- bzoj 3384: [Usaco2004 Nov]Apple Catching 接苹果
双倍经验题... -->1750 dp!! 3384: [Usaco2004 Nov]Apple Catching 接苹果 Time Limit: 1 Sec Memory Limit: 12 ...
- 苹果将通过新Apple TV打造电视游戏平台 欲发力家庭游戏(转)
据<纽约时报>报道,9月10日凌晨1时举行的苹果发布会上将会公布新版Apple TV设备,还会推出TV版App Store.新设备以游戏作为主要卖点,图形性能将大幅提升. 苹果2015年秋 ...
- BZOJ 3385: [Usaco2004 Nov]Lake Counting 数池塘
题目 3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec Memory Limit: 128 MB Description 农夫 ...
- 3386/1752: [Usaco2004 Nov]Til the Cows Come Home 带奶牛回家
3386/1752: [Usaco2004 Nov]Til the Cows Come Home 带奶牛回家 Time Limit: 1 Sec Memory Limit: 128 MBSubmit ...
- 3385: [Usaco2004 Nov]Lake Counting 数池塘
3385: [Usaco2004 Nov]Lake Counting 数池塘 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 22 Solved: 21 ...
- P3384: [Usaco2004 Nov]Apple Catching 接苹果
一道DP题, f[i,j,k] 表示 第 k 时刻 由 1 位置 变换 j 次 到达 当前 i 棵树 注意也要维护 变换 0 次的情况. var i,j,k,t,w,now:longint; tree ...
随机推荐
- matplotlib.pyplot.plot详解
参考资料: https://blog.csdn.net/baidu_41902768/article/details/80686608 之前的随笔也有说过,matplotlib是python中一个非常 ...
- 如何安装vim自动补全插件YouCompleteMe(YCM)
Vim是全平台上一个高度可拓展的编辑器.它本身只是一个简陋的编辑器,但是因为有各种插件而变得强大.使用Vim编写代码就不免遇到代码补全的问题.常用的代码补全插件有两个:日本人shougo写的neoco ...
- java基础——并发1
一.并发的定义 并发:对于这个概念一直就是没怎么搞懂,就是感觉特别的生疏,(自己从从字面上理解就是多个东西,一起出发),所以就上网上查了一些资料: 同时拥有两个或多个线程,如果程序在单核处理器上运行, ...
- 尚硅谷 dubbo学习视频
1 1.搭建zookpeer注册中心 windows下载zooker 需要修改下zoo_sample .cfg为zoo.cnf 然后需要zoo.cnf中数据文件的路径 第五步:把zoo_sample ...
- 洛谷 CF1012C Hills (动态规划)
题目大意:有n个山丘 , 可以在山丘上建房子 , 建房子的要求是 : 该山丘的左右山丘严格的矮于该山丘 (如果有的话),你有一架挖掘机,每单位时间可以给一个山丘挖一个单位的高度,问你想要建造 1,2, ...
- 【数位dp】CF 55D Beautiful numbers
题目 Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer n ...
- JavaScript常用API合集汇总(一)
今天这篇文章跟大家分享一些JavaScript常用的API代码,有DOM操作.CSS操作.对象(Object对象.Array对象.Number对象.String对象.Math对象.JSON对象和Con ...
- 正确卸载vs2015及以前版本方式
官网工具:https://github.com/Microsoft/VisualStudioUninstaller/releases 亲自测试过,很好用. (完)
- .netcore 网站启动后 502.5
网站启动后,报错 HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure 请检查安装的.netcore runtime版本和hosting版本是否 ...
- 初探pandas——安装和了解pandas数据结构
安装pandas 通过python pip安装pandas pip install pandas pandas数据结构 pandas常用数据结构包括:Series和DataFrame Series S ...