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 ...
随机推荐
- 图像的下采样Subsampling 与 上采样 Upsampling
I.目的 缩小图像(或称为下采样(subsampled)或降采样(downsampled))的主要目的: 1.使得图像符合显示区域的大小: 2.生成对应图像的缩略图. 放大图像(或称为上采样(ups ...
- jQuery UI =>jquery-ui.js中sortable方法拖拽对象位置偏移问题
今天要处理sortable方法处理的对象,拖拽的时候,位置偏移的问题. 按理应该是鼠标在哪,对象就跟着在哪的 百度了一下问题,http://blog.csdn.net/samed/article/de ...
- Oracle中的NULL、’’(空字符串)以及’_’(空格)
本文首发于 http://youngzy.com/ 在Oracle中使用 null,''(空字符串),'_'(空格)时,有没有遇到问题?产生疑惑? null和’’(空字符串)是一个意思 注: 为了便于 ...
- linux系统关闭指定服务的方式
1.根据名称称查找并关闭:pgrep -f 名称 | xargs kill -9 2.根据端口称查找并关闭:lsof -i:端口 | grep LISTEN|awk '{print $2}'|xarg ...
- nuxt跨域
根据nuxt官方文档提供的axios module 安装: npm install @nuxtjs/axios @nuxtjs/proxy --save nuxt.config.js modules: ...
- geotrellis使用(四十一)流水线技术
前言 之前 GeoTrellis 为方便用户将数据(GeoTiff 等遥感影像)导入到 backend (包含 Accumulo.File.Hadoop 等格式)中,编写了一个 ETL 类,该类的输入 ...
- 数据库的相关语句(where,order by)
select * from EMP t-- t列的别名--返回所有列 select ename || sal as HEHE from emp;--列的合并(使用连接) select concat(e ...
- 洛谷P3376 【模板】网络最大流
题目描述 如题,给出一个网络图,以及其源点和汇点,求出其网络最大流. 输入输出格式 输入格式: 第一行包含四个正整数N.M.S.T,分别表示点的个数.有向边的个数.源点序号.汇点序号. 接下来M行每行 ...
- 编译安装centos7 php7.2 mysql5.7 nginx1.9.9
2018年3月12日 14:09:39 注意时效 centos7 网卡 cd /etc/sysconfig/network-scripts/ TYPE=Ethernet PROXY_METHOD=no ...
- hadoop-1.0.1根目录下的jar包