区间DP
穷源溯流
路很长,尽管走便是。
展开
-
1574:矩阵取数游戏
首先先算出 n 行中每一行的最值,相加即可对于每一行来说,在区间 [i,j] 中,dp[i][j]=max(dp[i+1][j]+a[i]*2^i,dp[i][j-1]+a[j]*2^i)在开始之前,首先要处理一下,将谁放在最后一位提取,因为每一个数都可以是最后一个被提取的当然在实现过程中需要用到高精度,但我不会啊(逃)下面的代码只能过 6 个点const int N=100+5; int n,m,t; int i,j,k; ll a[N][N]...原创 2020-08-11 16:17:07 · 1207 阅读 · 0 评论 -
1573:分离与合体
const int N=300+5; int n,m,t; int i,j,k; int a[N]; int dp[N][N]; int ans[N][N];//储存区间 i~j 上的分界点void print(int l,int r,int step,int cnt){ if(l>=r) return ; int mid=ans[l][r]; if(cnt==step){ printf("%d ",mi...原创 2020-08-11 15:07:23 · 318 阅读 · 0 评论 -
1572:括号配对
const int N=400+5; int n,m,t; int i,j,k; //int a[N]; char ch[N]; int dp[N][N]; int main(){ IOS; while(cin>>ch+1){ n=strlen(ch+1); for(int len=2;len<=n;len++){ for(int i=1;i+len-1&l...原创 2020-06-30 17:13:20 · 479 阅读 · 0 评论 -
1570:能量项链
【题目描述】题做多了总会遇到重复的:原博客点击这里const int N=400+5; int n,m,t; int i,j,k; int a[N]; int head[N],tail[N]; int dp[N][N]; int main(){ IOS; while(cin>>n){ for(i=1;i<=n;i++) cin>>head[i],head[i+n]=head[i.原创 2020-06-30 16:58:10 · 414 阅读 · 0 评论 -
1569:石子合并
方程:dp[i][j]=dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]环形 dp 模板题const int N=400+5; int n,m,t; int i,j,k; int a[N]; int sum[N],dp_max[N][N],dp_min[N][N]; int main(){ IOS; while(cin>>n){ for(i=1;i<=n;i++){ ...原创 2020-06-30 16:40:12 · 576 阅读 · 0 评论 -
Food Delivery
When we are focusing on solving problems, we usually prefer to stay in front of computers rather than go out for lunch. At this time, we may call for food delivery.Suppose there are N people living ...原创 2020-04-28 11:49:33 · 1340 阅读 · 0 评论 -
Dire Wolf
Dire Wolf Time Limit: 5000/5000 MS (Java/Others)Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 5127Accepted Submission(s): 3060 Problem Description D...原创 2020-04-26 13:09:24 · 385 阅读 · 0 评论 -
String painter
String painter Time Limit: 5000/2000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 8471Accepted Submission(s): 4127 Problem Description ...原创 2020-04-26 13:08:07 · 376 阅读 · 0 评论 -
能量项链
Description 在Mars星球上,每个Mars人都随身佩带着一串能量项链。在项链上有N颗能量珠。能量珠是一颗有头标记与尾标记的珠子,这些标记对应着某个正整数。并且,对于相邻的两颗珠子,前一颗珠子的尾标记一定等于后一颗珠子的头标记。因为只有这样,通过吸盘(吸盘是Mars人吸收能量的一种器官)的作用,这两颗珠子才能聚合成一颗珠子,同时释放出可以被吸盘吸收的能量。如果前一颗能量珠的头...原创 2020-04-26 13:00:40 · 394 阅读 · 0 评论 -
Battle Ships
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense tower, which has L longevity. The player has a military factory, which can produce N kinds of battle...原创 2020-04-26 12:58:48 · 252 阅读 · 0 评论 -
Running
Language: Running Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8558 Accepted: 3201 Description The cows are trying to become better ...原创 2020-04-26 12:48:35 · 277 阅读 · 0 评论 -
Cheapest Palindrome
Language: Cheapest Palindrome Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 16164 Accepted: 7548 Description Keeping track of all the...原创 2020-04-26 12:45:44 · 202 阅读 · 0 评论 -
Multiplication Puzzle
Language: Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16436 Accepted: 10086 Description The multiplication puz...原创 2020-04-26 12:42:55 · 308 阅读 · 0 评论 -
Halloween Costumes
Gappu has a very busy weekend ahead of him. Because, next weekend is Halloween, and he is planning to attend as many parties as he can. Since it's Halloween, these parties are all costume parties, ...原创 2020-04-26 12:37:45 · 587 阅读 · 0 评论 -
Palindrome subsequence(带子序列的区间DP)
Palindrome subsequence Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 131072/65535 K (Java/Others) Total Submission(s): 5345Accepted Submission(s): 2323 Problem Descr...原创 2020-04-25 14:20:09 · 311 阅读 · 0 评论 -
Brackets
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17610 Accepted: 9093 Description We give the following inductive definition of a “...原创 2020-04-08 22:31:39 · 253 阅读 · 0 评论