3384/1750: [Usaco2004 Nov]Apple Catching 接苹果
3384/1750: [Usaco2004 Nov]Apple Catching 接苹果
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 18 Solved: 16
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
2
1
1
2
2
1
1
Sample Output
HINT
7分钟内共掉落7个苹果一一第1个从第2棵树上掉落,接下来的2个苹果从第1棵树上掉落,再接下来的2个从第2棵树上掉落,最后2个从第1棵树上掉落. 贝茜不移动直到接到从第1棵树上掉落的两个苹果,然后移动到第2棵树下,直到接到从第2棵
树上掉落的两个苹果,最后移动到第1棵树下,接住最后两个从第1棵树上掉落的苹果.这样贝茜共接住6个苹果.
Source
题解:一道有趣的DP问题,设f[i,j,k]表示现在时间为i,已经跑了j次,当前在k树下面的最优解,于是f[i,j,k]:=longint(a[i]=k)+min(a[i-1,j,k],a[i-1,j-1,3-k]),这两种情况分别代表直接继承上一时间位置和本次进行了一次走动,然后当a[i]=k时,longint(a[i]=k)=1,也就是苹果数+1,否则不加。。。(循环数组就是萌萌哒不解释)
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
i,j,k,l,m,n:longint;
a:array[..] of longint;
b:array[..,..,..] of longint;
function max(x,y:longint):longint;
begin
if x>y then max:=x else max:=y;
end;
begin
readln(n,m);
for i:= to n do readln(a[i]);
fillchar(b,sizeof(b),);
for i:= to n do
for j:= to m do
for k:= to do
begin
l:=b[(i+) mod ,j,k];
if j> then l:=max(b[(i+) mod ,j-,-k],l);
b[i mod ,j,k]:=longint(a[i]=k)+l;
end;
l:=;
for i:= to m do
for j:= to do
l:=max(l,b[n mod ,i,j]);
writeln(l);
readln;
end.
呵呵呵我会告诉你下面还有一遍?么么哒我是有多无聊= =(HansBug:不过双倍经验还是好评如潮^_^)
/**************************************************************
Problem:
User: HansBug
Language: Pascal
Result: Accepted
Time: ms
Memory: kb
****************************************************************/ var
i,j,k,l,m,n:longint;
a:array[..] of longint;
b:array[..,..,..] of longint;
function max(x,y:longint):longint;
begin
if x>y then max:=x else max:=y;
end;
begin
readln(n,m);
for i:= to n do readln(a[i]);
fillchar(b,sizeof(b),);
for i:= to n do
for j:= to m do
for k:= to do
begin
l:=b[(i+) mod ,j,k];
if j> then l:=max(b[(i+) mod ,j-,-k],l);
b[i mod ,j,k]:=longint(a[i]=k)+l;
end;
l:=;
for i:= to m do
for j:= to do
l:=max(l,b[n mod ,i,j]);
writeln(l);
readln;
end.
3384/1750: [Usaco2004 Nov]Apple Catching 接苹果的更多相关文章
- 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 ...
- bzoj 3384: [Usaco2004 Nov]Apple Catching 接苹果
双倍经验题... -->1750 dp!! 3384: [Usaco2004 Nov]Apple Catching 接苹果 Time Limit: 1 Sec Memory Limit: 12 ...
- bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*
bzoj3384[Usaco2004 Nov]Apple Catching 接苹果 bzoj1750[Usaco2005 qua]Apple Catching 题意: 两棵树,每分钟会从其中一棵树上掉 ...
- P3384: [Usaco2004 Nov]Apple Catching 接苹果
一道DP题, f[i,j,k] 表示 第 k 时刻 由 1 位置 变换 j 次 到达 当前 i 棵树 注意也要维护 变换 0 次的情况. var i,j,k,t,w,now:longint; tree ...
- Apple Catching(POJ 2385)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9978 Accepted: 4839 De ...
- Apple Catching(dp)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9831 Accepted: 4779 De ...
- POJ2385——Apple Catching
$Apple~Catching$ Time Limit: 1000MS Memory Limit: 6553 ...
- 【POJ】2385 Apple Catching(dp)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13447 Accepted: 6549 D ...
- 【POJ - 2385】Apple Catching(动态规划)
Apple Catching 直接翻译了 Descriptions 有两棵APP树,编号为1,2.每一秒,这两棵APP树中的其中一棵会掉一个APP.每一秒,你可以选择在当前APP树下接APP,或者迅速 ...
随机推荐
- Servlet 应用程序事件、监听器
Web容器管理Servlet/JSP相关的生命周期,若对HttpServletRequest对象.HttpSession对象.ServletContxt对象在生成.销毁或相关属性设置发生的时机点有兴趣 ...
- Spring classPath:用法
http://blog.csdn.net/xing_sky/article/details/8228305 参考文章地址: http://hi.baidu.com/huahua035/item/ac8 ...
- 在Flex中定义移动设备应用程序和启动屏幕
创建移动设备应用程序容器 移动设备应用程序中的第一个标签通常是以下标签之一: <s:ViewNavigatorApplication> 标签用于定义只有一个部分的移动设备应用程序. < ...
- IE的缓存
例:在IE中缓存是很难清掉的,用户也不会每次都给你点清理缓存,那是开发人员自己开发才会干的事,所以我们在对接数据的时候,最好采用异步刷新的方式,获取最新数据 方法如下: // 异步刷新,针对IE缓存的 ...
- 关于在官网上下载Eclipse遇到的问题!!
首先Eclipse是什么? Eclipse 是一个开放源代码的.基于Java的可扩展开发平台.就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境. 幸运的是,Eclipse 附带了一 ...
- CodeForces 460B
Little Dima and Equation Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & ...
- HDU1494(dp)
跑跑卡丁车 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- android:在ViewPager中使用Button
最近在项目用用到ViewPager ,其中页面包含有Button,因为之前也有使用个ViewPager ,所以这个也照搬之前的方式,测试后发现点击button无法执行,这个button是在第一页面的默 ...
- 制作一个功能丰富的Android天气App
简易天气是一个基于和风天气数据采用MD设计的Android天气App.目前的版本采用传统的MVC模式构建.通过丰富多彩的页面为用户提供日常所需的天气资讯. 项目说明 项目放在github上面 地址是: ...
- html 一般标签 常用标签 表格
body的属性: bgcolor 页面背景色 background 背景壁纸.图片 text 文字颜色 top ...