题目链接

区间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的更多相关文章

  1. HDU5115 Dire Wolf(区间DP)

    渐渐认识到区域赛更侧重的是思维及基本算法的灵活运用,而不是算法的量(仅个人见解),接下来要更多侧重思维训练了. 区间DP,dp[i][j]表示从i到j最终剩余第i 与第j只的最小伤害值,设置0与n+1 ...

  2. hdu5115 Dire Wolf【区间dp】

    转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4361169.html   ---by 墨染之樱花 [题目链接]http://acm.hdu.e ...

  3. Dire Wolf——HDU5115(区间DP)

    题意 就是有一对狼,每个狼有初始的攻击力,并且还能给左右两边的狼提供攻击力加成,当冒险家杀死一头狼的时候他也会受到这个狼目前攻击力的伤害 实例解析 33 5 78 2 0 有三头狼,刚开始第二头狼给他 ...

  4. Dire Wolf——HDU5115

    Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not ...

  5. HDU 5115 Dire Wolf 区间dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5115 Dire Wolf Time Limit: 5000/5000 MS (Java/Others ...

  6. 动态规划(区间DP):HDU 5115 Dire Wolf

    Dire wolves, also known as Dark wolves, are extraordinarily large and powerful wolves. Many, if not ...

  7. hdu 5115 Dire Wolf(区间dp)

    Problem Description Dire wolves, also known as Dark wolves, are extraordinarily large and powerful w ...

  8. Dire Wolf(区间DP)

    Dire Wolf Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total ...

  9. Dire Wolf HDU - 5115(区间dp)

    Dire Wolf Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total ...

随机推荐

  1. Oracle 19C的下载和安装部署(图形安装和静默安装)

    Oracle 19C的下载和安装部署(图形安装和静默安装)   https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/ ...

  2. c# 正则

    Regex reg = new Regex("^do(es)(xy)?$"); var result = reg.Match("doesxy"); foreac ...

  3. <转>从K近邻算法、距离度量谈到KD树、SIFT+BBF算法

    转自 http://blog.csdn.net/likika2012/article/details/39619687 前两日,在微博上说:“到今天为止,我至少亏欠了3篇文章待写:1.KD树:2.神经 ...

  4. 【微信开发】cURL error 60: SSL certificate problem: unable to get local issuer certificate (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

    在做微信开发时候,请求为你接口报错: 解决方案: 1 下载cacert https://curl.haxx.se/ca/cacert.pem 2 修改 php.ini , 并重启 curl.cainf ...

  5. Qt编写自定义控件7-自定义可拖动多边形

    前言 自定义可拖动多边形控件,原创作者是赵彦博(QQ:408815041 zyb920@hotmail.com),创作之初主要是为了能够在视频区域内用户自定义可拖动的多个区域,即可用来作为警戒区域,也 ...

  6. Python中的test测试

    不知道怎么回事,打开的工程中出现了pytest,难道是检测到了我的命名中有test吗? 参考博文:https://blog.csdn.net/weixin_41605937/article/detai ...

  7. Coffee and Coursework (Hard Version)

    Coffee and Coursework (Hard Version) time limit per test 2.5 seconds memory limit per test 256 megab ...

  8. ajax方式提交表单数据并判断当前注册用户是否存在

    项目的目录结构 源代码: regservlet.java package register; import java.io.IOException; import java.io.PrintWrite ...

  9. python全栈开发 * 线程锁 Thread 模块 其他 * 180730

    一,线程Thread模块1.效率更高(相对于进程) import time from multiprocessing import Process from threading import Thre ...

  10. spring 开始构造

    1,选择“org.apache.maven.archetypes:maven-archetype-webapp”骨架(模板),创建一个Web项目: 在main 目录下创建文件夹  java,  res ...