hdu5115 Dire Wolf
题目链接
区间DP
$dp_{i,j}$为杀掉$i~j$内的狼的最小代价
枚举$i~j$中最后杀掉的狼,$dp_{i,j}=min\{ { {k\in{[i,j]}} | dp_{i,k-1}+dp_{k+1,j}+A_k+B_{i-1}+B_{j+1}} \}$
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
#define re(i,l,r) for(int i=(l);i<=(r);i++)
#define rre(i,r,l) for(int i=(r);i>=(l);i--)
using namespace std;
typedef long long LL;
int t,A[],B[],n;
LL hh[][];
LL dfs(int l,int r)
{
LL &ret=hh[l][r];
if(ret)return ret;
ret=1LL<<;
if(l>r)return ret=;LL now=B[l-]+B[r+];
re(i,l,r)ret=min(dfs(l,i-)+dfs(i+,r)+A[i]+now,ret);
return ret;
}
int main()
{
scanf("%d",&t);int tt=t;
while(t--)
{
printf("Case #%d: ",tt-t);
memset(hh,,sizeof(hh));
scanf("%d",&n);
re(i,,n)scanf("%d",&A[i]);
re(i,,n)scanf("%d",&B[i]);
printf("%lld\n",dfs(,n));
}
return ;
}
hdu5115 Dire Wolf的更多相关文章
- HDU5115 Dire Wolf(区间DP)
渐渐认识到区域赛更侧重的是思维及基本算法的灵活运用,而不是算法的量(仅个人见解),接下来要更多侧重思维训练了. 区间DP,dp[i][j]表示从i到j最终剩余第i 与第j只的最小伤害值,设置0与n+1 ...
- hdu5115 Dire Wolf【区间dp】
转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4361169.html ---by 墨染之樱花 [题目链接]http://acm.hdu.e ...
- Dire Wolf——HDU5115(区间DP)
题意 就是有一对狼,每个狼有初始的攻击力,并且还能给左右两边的狼提供攻击力加成,当冒险家杀死一头狼的时候他也会受到这个狼目前攻击力的伤害 实例解析 33 5 78 2 0 有三头狼,刚开始第二头狼给他 ...
- Dire Wolf——HDU5115
Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not ...
- HDU 5115 Dire Wolf 区间dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5115 Dire Wolf Time Limit: 5000/5000 MS (Java/Others ...
- 动态规划(区间DP):HDU 5115 Dire Wolf
Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not ...
- hdu 5115 Dire Wolf(区间dp)
Problem Description Dire wolves, also known as Dark wolves, are extraordinarily large and powerful w ...
- Dire Wolf(区间DP)
Dire Wolf Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total ...
- Dire Wolf HDU - 5115(区间dp)
Dire Wolf Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others)Total ...
随机推荐
- windows安装mongodb服务简洁版教程
根据网上安装教程,简单总结如下: 1.去mongodb官网下载电脑系统对应版本的软件,比如我的是windows 64位的,就选择64位的,可能下载下来之后文件夹上面显示的是win32,这个不用理会: ...
- ABBYY PDF Transformer+支持的格式
ABBYY PDF Transformer+是一个新的,全面的巧妙解决PDF文档的工具,它将泰比的光学字符识别(OCR)技术和Adobe®PDF技术完美结合,以确保实现便捷地处理任何类型的PDF文件, ...
- zookeeper使用
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,它包含一个简单的原语集,分布式应用程序可以基于它实现同步服务,配置维护和命名服务等.Zookeeper是hadoop的一个子项目,其 ...
- pom.xml文件最详细的讲解
1 引入额外的jar包 <dependency> <groupId>bitwalker</groupId> <artifactId>UserAgentU ...
- H5常用技巧
工作每天都是接触移动的,特将平时工作中常用的技巧整理总结. 一.@support断定浏览器支持情况定义不同样式 @1像素边框 @supports (-webkit-backdrop-filter:bl ...
- [LeetCode] Basic Calculator IV 基本计算器之四
Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {&q ...
- java导入、导出Excel文件
一.介绍 当前B/S模式已成为应用开发的主流,而在企业办公系统中,常常有客户这样子要求:你要把我们的报表直接用Excel打开(电信系统.银行系统).或者是:我们已经习惯用Excel打印.这样在我们实际 ...
- upstream模块介绍
upstream模块介绍 Nginx的负载均衡功能依赖于ngx_http_upsteam_module模块,所支持的代理方式包括proxy_pass.fastcgi_pass.memcached_pa ...
- sublime插件之px转rem
sublime插件之px转rem 安装: 1.下载sublime并安装: 2.下载cssrem:https://github.com/hyb628/cssrem: 3.找到 Packages (首 ...
- python的几个小程序
##九九乘法口诀 num1=1 while num1<10: num2=1 while num2<=num1: print(num2,"*",num1,"=& ...