BZOj1261: [SCOI2006]zh_tree(dp)
Time Limit: 10 Sec Memory Limit: 162 MB
Submit: 400 Solved: 272
[Submit][Status][Discuss]
Description
Input
Output
Sample Input
20 30 50 20
Sample Output
HINT
Source
并不是很懂题目是什么意思。。
网上的题解也没有说这题的思路,只是给了一个很脑残的dp方程。。
总感觉这题可以直接贪心搞过去。
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int MAXN = 1e5 + , INF = 1e9 + ;
inline int read() {
char c = getchar(); int x = , f = ;
while(c < '' || c > '') {if(c == '-') f = -; c = getchar();}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int N;
double K, C, f[][];
int a[MAXN];
double dp(int l, int r) {
if(l > r) return ;
if(f[l][r] != INF) return f[l][r];
for(int i = l; i <= r; i++)
f[l][r] = min(f[l][r], dp(l, i - ) + dp(i + , r) + (a[i] - a[i - ]) * C / a[N] );
return f[l][r] = f[l][r]+ K / a[N] * (a[r] - a[l - ]);
}
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
scanf("%d %lf %lf", &N, &K, &C);
for(int i = ; i <= N; i++) a[i] = a[i - ] + read();
for(int i = ; i <= N; i++)
for(int j = ; j <= N; j++)
f[i][j] = INF;
printf("%.3lf", dp(, N));
}
BZOj1261: [SCOI2006]zh_tree(dp)的更多相关文章
- bzoj千题计划184:bzoj1261: [SCOI2006]zh_tree
http://www.lydsy.com/JudgeOnline/problem.php?id=1261 dp[l][r][dep] 区间[l,r]内的节点,根在dep层的最小代价 枚举根i,dp[ ...
- BZOJ1261: [SCOI2006]zh_tree
Description 张老师根据自己工作的需要,设计了一种特殊的二叉搜索树.他把这种二叉树起名为zh_tree,对于具有n个结点的zh_tree,其中序遍历恰好为(1,2,3,-,n),其中数字1, ...
- BZOJ 1261: [SCOI2006]zh_tree( 区间dp )
dp(l, r)表示[l, r]这段作为一棵树的最小访问代价. 对于dp(l, r), 我们枚举它的根x, 则dp(l, r) = min(dp(l, x-1)+dp(x+1, r)+C*fx) + ...
- 「 洛谷 」P4539 [SCOI2006]zh_tree
小兔的话 推荐 小兔的CSDN [SCOI2006]zh_tree 题目限制 内存限制:250.00MB 时间限制:1.00s 标准输入输出 题目知识点 思维 动态规划 \(dp\) 区间\(dp\) ...
- 【DP】【P4539】 [SCOI2006]zh_tree
Description 张老师根据自己工作的需要,设计了一种特殊的二叉搜索树. 他把这种二叉树起名为zh_tree,对于具有n个结点的zh_tree,其中序遍历恰好为(1,2,3,-,n),其中数字1 ...
- 区间DP复习
区间DP复习 (难度排序:(A,B),(F,G,E,D,H,I,K),(C),(J,L)) 这是一个基本全在bzoj上的复习专题 没有什么可以说的,都是一些基本的dp思想 A [BZOJ1996] [ ...
- Noip前的大抱佛脚----赛前任务
赛前任务 tags:任务清单 前言 现在xzy太弱了,而且他最近越来越弱了,天天被爆踩,天天被爆踩 题单不会在作业部落发布,所以可(yi)能(ding)会不及时更新 省选前的练习莫名其妙地成为了Noi ...
- bzoj AC倒序
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem ...
- dp专练
dp练习. codevs 1048 石子归并 区间dp #include<cstdio> #include<algorithm> #include<cstring> ...
随机推荐
- 提取url中参数的方法(转换成json格式)
还是直接上代码吧. //将url中的参数获取到并抓换成json格式 function serilizeUrl(url){ var urlObject={}; //1.正则匹配是不是以?结尾 if(/\ ...
- [PAMI 2018] Differential Geometry in Edge Detection: accurate estimation of position, orientation and curvature
铛铛铛,我的第一篇文章终于上线了,过程曲折,太不容易了--欢迎访问--- https://ieeexplore.ieee.org/document/8382271/ 后面有需要的话可以更新一下介绍,毕 ...
- sqlServer拼结列字符串
with table1(sessionID,message,createTime)as(select 1 ,'hello' ,'2014/5/6' union allselect 1 ,'word' ...
- 开通cnblogs博客
开通博客,准备记录学习和开发过程
- Git学习1:Git起步
本系列文章部分原理和命令相关内容是从 https://git-scm.com/book/zh/v2 摘录,软件实际使用是总结自己的实践经验成文. 1. 关于版本控制 版本控制是一种记录一个或若干文件内 ...
- 安装adobe,路径My Pictures或卷无效。请重新输入。
问题:安装adobe reader时,路径My Pictures或卷无效.请重新输入.我的光驱是D盘.因为是在虚拟机下安装的xp系统. 解决办法: GHOST WINXP2 My Pictures一般 ...
- May 31st 2017 Week 22nd Wednesday
No great discovery was ever made without a bold guess. 没有大胆的猜测就没有伟大的发现. When our ancestors saw the b ...
- March 14 2017 Week 11 Tuesday
Thinking will not overcome fear but action will. 空想终日惶恐,行动方可无惧. As the deadline comes closer and clo ...
- 插上翅膀,让Excel飞起来——xlwings(三)
xlwings基本对象 xlwings基本对象 App相当于Excel程序,Book相当于工作簿.N个Excel程序则由apps表示,N个工作簿由books表示. 对工作簿的操作 #导入xlwings ...
- 108. Convert Sorted Array to Binary Search Tree (building tree with resursion)
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. Fo ...