P3384: [Usaco2004 Nov]Apple Catching 接苹果
一道DP题, f[i,j,k] 表示 第 k 时刻 由 1 位置 变换 j 次 到达 当前 i 棵树 注意也要维护 变换 0 次的情况。
var i,j,k,t,w,now:longint;
tree:array[..,..] of longint;
f:array[..,..,..] of longint;
function max(a,b:longint):longint;
begin
if a>b then exit(a)
else exit(b);
end;
begin
readln(t,w);
for i:= to t do
begin
readln(now);
tree[now,i]:=;
end;
for i:= to t do
for j:= to w+i-max(i,w) do
for k:= to do
begin
if (j=) and (k<>) then begin
f[k,j,i]:=f[k,j,i-]+tree[k,i];
continue;
end
else if j= then continue;
f[k,j,i]:=max(f[k,j,i],tree[k,i]+max(f[-k,j-,i-],f[k,j,i-]));
//writeln(i,' ',j,' ',f[k,j,i]);
end;
writeln(max(f[,w,t],f[,w,t]));
end.
(转载请注明出处:http://www.cnblogs.com/Kalenda/)
P3384: [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 ...
- 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 ...
- bzoj3384[Usaco2004 Nov]Apple Catching 接苹果*&&bzoj1750[Usaco2005 qua]Apple Catching*
bzoj3384[Usaco2004 Nov]Apple Catching 接苹果 bzoj1750[Usaco2005 qua]Apple Catching 题意: 两棵树,每分钟会从其中一棵树上掉 ...
- 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,或者迅速 ...
随机推荐
- Windows phone 8 学习笔记(2) 数据文件操作(转)
Windows phone 8 应用用于数据文件存储访问的位置仅仅限于安装文件夹.本地文件夹(独立存储空间).媒体库和SD卡四个地方.本节主要讲解它们的用法以及相关限制性.另外包括本地数据库的使用方式 ...
- Linux:一台apache服务器上部署多个项目的apache配置
第一步: 将代码取到/var/www/html目录下(此为默认目录,具体看apache的设置):该目录下可以放多个项目,如: [root@www html]# pwd/var/www/html[roo ...
- Android IOS WebRTC 音视频开发总结(三八)-- tx help
本文主要介绍帮一个程序员解决webrtc疑问的过程,文章来自博客园RTC.Blacker,支持原创,转载请说明出处(www.rtc.help) 这篇文章内容主要来自邮件,为什么我会特别整理到随笔里面来 ...
- 破解Demo
需要破解的程序界面如下: 需要破解的程序的主要代码如下: void CEasyCrackMeDlg::OnBnClickedButtonOk() { // TODO: 在此添加控件通知处理程序代码 T ...
- iConvert Icons 图标转换生成利器,支持Windows, Mac OS X, Linux, iOS,和Android等系统
这是一款在线图标转换工具,生成的图标支持Windows, Mac OS X, Linux, iOS, 和 Android等主流系统. 可以上传图标文件转化成另一个平台下的图标文件,例如将windows ...
- html5 canvas画板
点击查看演示地址 <!DOCTYPE HTML> <html> <title>HTML5-CanvasDrawDemo</title> <meta ...
- foreach 和 list.foreach 初步测试
单纯从速度上讲 小数据量下foreach 较快,list.Foreach 由于 public void ForEach(Action<T> action) { ; i <this._ ...
- table中绝对定位元素相对td定位失效解决方案
开门见山! 问题:在一个table中,我需要在td里面绝对定位一个div, 写法:td{position:relative;} div{position:absolute;} OK,就这么简单,思路也 ...
- Spark基础排序+二次排序(java+scala)
1.基础排序算法 sc.textFile()).reduceByKey(_+_,).map(pair=>(pair._2,pair._1)).sortByKey(false).map(pair= ...
- 并行编程之CountdownEvent的用法
教程:http://blog.gkarch.com/threading/part5.html#the-parallel-class http://www.cnblogs.com/huangxinche ...