hdu-5653 Bomber Man wants to bomb an Array.(区间dp)
题目链接:
Bomber Man wants to bomb an Array.
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 382 Accepted Submission(s): 114
Each Bomb has some left destruction capability L and some right destruction capability R which means if a bomb is dropped at ith location it will destroy L blocks on the left and R blocks on the right.
Number of Blocks destroyed by a bomb is L+R+1
Total Impact is calculated as product of number of blocks destroyed by each bomb.
If ith bomb destroys Xi blocks then TotalImpact=X1∗X2∗....Xm
Given the bombing locations in the array, print the Maximum Total Impact such that every block of the array is destoryed exactly once(i.e it is effected by only one bomb).
### Rules of Bombing
1. Bomber Man wants to plant a bomb at every bombing location.
2. Bomber Man wants to destroy each block with only once.
3. Bomber Man wants to destroy every block.
First line two Integers N and M which are the number of locations and number of bombing locations respectivly.
Second line contains M distinct integers specifying the Bombing Locations.
1 <= N <= 2000
1 <= M <= N
Hint:
Sample 1:
Sample 2:
/*
Problem : 5653 ( Bomber Man wants to bomb an Array. ) Judge Status : Accepted
RunId : 16703569 Language : G++ Author : 2014300227
*/
#include <bits/stdc++.h>
using namespace std;
int n,m,a[];
double dp[][];
const double N=;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i=;i<=m;i++)
for(int j=;j<=n;j++)
dp[i][j]=;
for(int i=;i<=m;i++)
{
scanf("%d",&a[i]);
a[i]++;
}
a[]=;
a[m+]=n+;
sort(a,a+m+);
for(int i=;i<a[];i++)
{
dp[][i]=log10(i*1.0)/log10(2.0)*N;
}
for(int i=;i<=m;i++)
{
for(int j=a[i];j<a[i+];j++)
{
for(int k=a[i-];k<a[i];k++)
{
dp[i][j]=max(dp[i][j],dp[i-][k]+log10((j-k)*1.0)/log10()*N);
}
}
}
int ans=(int)(dp[m][n]);
printf("%d\n",ans);
} return ;
}
hdu-5653 Bomber Man wants to bomb an Array.(区间dp)的更多相关文章
- HDU 5653 Bomber Man wants to bomb an Array. dp
Bomber Man wants to bomb an Array. 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5653 Description ...
- hdu 5653 Bomber Man wants to bomb an Array
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5653 题意:已知炸弹可以炸掉左边L个位置,右边R个位置,那么炸点炸掉的总数是L+R+1.给定每个炸弹的 ...
- HDU5653 Bomber Man wants to bomb an Array 简单DP
题意:bc 77 div1 1003(中文题面) 分析:先不考虑将结果乘以 1e6. 设 dp[i] 为从前 i 个格子的状态可以获得的最大破坏指数. 那么我们可以枚举每个炸弹,该炸弹向左延伸的距离和 ...
- [hdu contest 2019-07-29] Azshara's deep sea 计算几何 动态规划 区间dp 凸包 graham扫描法
今天hdu的比赛的第一题,凸包+区间dp. 给出n个点m个圆,n<400,m<100,要求找出凸包然后给凸包上的点连线,连线的两个点不能(在凸包上)相邻,连线不能与圆相交或相切,连线不能相 ...
- HDU 4283 You Are the One (12年天津 区间DP)
题意:有一个队列,每个人有一个愤怒值a[i],如果他是第k个上场,不开心指数就为(k-1)*a[i].但是边上有一个小黑屋(其实就是个堆栈),可以一定程度上调整上场程序 思路:枚举区间和每个人第几个上 ...
- HDU 4283---You Are the One(区间DP)
题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4283 Problem Description The TV shows such as Y ...
- HDU 4293---Groups(区间DP)
题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4293 Problem Description After the regional con ...
- hdu 4597 + uva 10891(一类区间dp)
题目链接:http://vjudge.net/problem/viewProblem.action?id=19461 思路:一类经典的博弈类区间dp,我们令dp[l][r]表示玩家A从区间[l, r] ...
- HDU 1565&1569 方格取数系列(状压DP或者最大流)
方格取数(2) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S ...
随机推荐
- textarea中的内容的获取
今天他们说为啥获取不到textarea的数值 这个问题让我很纳闷 为什么会获取不到呢? 按照逻辑来说 同样都是表单元素 怎么可能出现呢? 我就看了一眼代码 alert($("#texta ...
- python tensorflow 学习
Tensorflow系列——Saver的用法:http://blog.csdn.net/u011500062/article/details/51728830 Tensorflow学习系列(二): t ...
- 自定义 ViewController 容器转场
本文转载至 http://blog.csdn.net/yongyinmg/article/details/40621463 在话题 #5 中,Chris Eidhof 向我们介绍了 iOS7 引入的新 ...
- MySQL 下 ROW_NUMBER / DENSE_RANK / RANK 的实现
原文链接:http://hi.baidu.com/wangzhiqing999/item/7ca215d8ec9823ee785daa2b MySQL 下 ROW_NUMBER / DENSE_RAN ...
- devexpress gridcontrol如何遍历每一行
List<Medicine> medicinelist = new List<Medicine>(); foreach (GridViewRow row in GridView ...
- The hidden layers are either convolutional, pooling or fully connected.
https://en.wikipedia.org/wiki/Convolutional_neural_network Convolutional layers apply a convolution ...
- 关于iOS的手势UIGestureRecognizer问题
typedef NS_ENUM(NSInteger, UIGestureRecognizerState) { UIGestureRecognizerStatePossible, // 尚未识别是何种手 ...
- 【python】-- json & pickle、xml、requests、hashlib、shelve、shutil、configparser、subprocess
json & pickle Python中用于序列化的两个模块 json 用于[字符串]和 [python基本数据类型] 间进行转换 pickle 用于[python特有的类型] ...
- 让lu哥头痛了许久的代码(洛谷:树的统计)
错在单点修改时传的是a,应该是id[a](Line 89).谨记!!! //fushao zuishuai #include <cstdio> #include <cstring&g ...
- Jquery定义对象( 闭包)
转自:http://www.cnblogs.com/springsnow/archive/2010/06/03/1750832.html 例一:添加对象的静态属性 声明一个对象$.problemWo, ...