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 ...
随机推荐
- 记PHP下载大文件失败的一次坑
说明 php提供文件的储存和下载,nginx作为web服务器,fpm做解析. 现象 当下载一个5M大小的图片时,总提示下载失败,或下载下来的文件不完整,仅显示部分图像(每次下载不一样) php下载相关 ...
- vue 生成二维码+截图
链接生成二维码 1.npm安装 npm install --save qrcodejs2 2.引入 import QRCode from 'qrcodejs2' 3.生成二维码 new QRCode( ...
- Linux常用命令之文件磁盘管理
前言 本文知识点是曾经学习过程中收录整理的,方便学习使用. 一>Linux常用基本命令 Linux命令格式:command [-options] [parameter1] ... command ...
- Spring:如何实现注解的组合
Spring中存在很多注解组合的情况,例如@RestController @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @ ...
- Pytorch入门——手把手带你配置云服务器环境
本文始发于个人公众号:TechFlow,原创不易,求个关注 今天这篇是Pytorch专题第一篇文章. 大家好,由于我最近自己在学习Pytorch框架的运用,并且也是为了响应许多读者的需求,推出了这个P ...
- JS中style.display和style.visibility的区别
在JS中可以通过设置style.display或者style.visibility属性来控制元素是否显示,在style.display=block和style.visibility=visible的时 ...
- 三分钟在任何电脑上使用 chrome os
准备 什么是 chrome os? Chrome OS是一款Google开发的基于PC的操作系统. Google Chrome OS是一款基于Linux的开源操作系统. Chrome OS 系统和 C ...
- jQurey Validation 1.16
https://jeesite.gitee.io/front/jquery-validation/1.16/demo/index.html
- web前端开发入门全套学习方法路径,兼职在家做网站也能月入上万!
前端学习路径 1.WEB前端快速入门 在本阶段,我们需要掌握 HTML 与 CSS 基础,当然,也包含 H5 和 C3 的新特性.这个部分内容非常简单,而且非常容易掌握.相信你也更愿意学习这个部分,毕 ...
- '%' For instance '%d'
with each % indicating where one of the other (second, third, ...) arguments is to be substituted, a ...