1 最大连续子序列
http://acm.hdu.edu.cn/showproblem.php?pid=1231
状态转移方程:
if (a[i]>start[i-1]+a[i]) { start[i]=a[i] ; lef[i]=i; }
else {start[i] =start[i-1] +a[i] ; lef[i]=lef[i-1] ; }
2最大递增子段
http://acm.hdu.edu.cn/showproblem.php?pid=1087
给定几点,后取得数大于前面的数,求最大和
状态转移方程:
for(i=1;i<=n+1;i++) {
for(j=0;j<i;j++) {
if(a[i]>a[j]) {
if(start[i]<start[j]+a[i]) start[i]=start[j]+a[i];
} } }
3 Largest Rectangle in a Histogram
http://acm.hdu.edu.cn/showproblem.php?pid=1506
给定各木板长度,底对齐排在一起,求最大面积
for( i=1 ; t= i, i<=n ;i++){
while( t!=1 && a[i]<= a[t-1]){
t= lef[t-1]; } lef[i]= t;
}
for( i=n; t=i, i>=1; i--){
while( t!=n && a[i]<= a[t+1]){
t= rig[t+1]; } rig[i]= t;
}
分别向左向右迭代,该块木板高度时,左右可达位置,用以求宽度
4 City Game
http://acm.hdu.edu.cn/showproblem.php?pid=1505
1056加强版 二维
for( i=1; i<=m; i++){
for( j=1; j<=n; j++){
scanf("%s", ch);
if( ch[0]== 'F'){
hig[j]++;
}
else{
hig[j]= 0;
}
}
tt= dp(); //向左右分别求此高度下的能达位置
if( tt>ans)
ans= tt;
}
5 LITTLE SHOP OF FLOWERS
http://poj.org/problem?id=1157
给定一些花来装饰窗台,必须按给定的顺序摆放花,每种花放在每个花瓶中有一个美观度,求最大美观度
for( i= 1; i<=f; i++){
dp[i][i]= dp[i-1][i-1]+ a[i][i];
for( j=i+1; j<=v; j++)
dp[i][j]= max( dp[i-1][j-1]+a[i][j], dp[i][j-1]);
}
6 滑雪
http://poj.org/problem?id=1088
记忆化搜索
DP(i,j) = max( DP(i,j-1), DP(i,j+1), DP(i-1,j), DP(i+1,j) ) + 1;