题意为从每行取一瓶花,每瓶花都有自己的审美价值

第 i+1 行取的花位于第 i 行的右下方

求最大审美价值

dp[i][j]:取到第 i 行,第 j 列时所获得的最大审美价值

动态转移方程:dp[i][j]=max(dp[i-1][j-1]+a[i][j],dp[i][j-1])

代码如下:

#include<stdio.h>
int dp[][];
int a[][];
int Max(int x,int y)
{
return x>y?x:y;
}
int main()
{
int f,v;
while(scanf("%d%d",&f,&v)!=EOF)
{
for(int i=; i<=f; i++)
for(int j=; j<=v; j++)
{
scanf("%d",&a[i][j]);
dp[i][j]=-;
}
dp[][]=a[][];
for(int i=; i<=v; i++) //初始化dp[1][2~v]
dp[][i]=Max(dp[][i-],a[][i]);
for(int i=; i<=f; i++)
for(int j=i; j<=v; j++) //注意从i开始,,上一行的右下方
{
dp[i][j]=Max(dp[i-][j-]+a[i][j],dp[i][j-]);
}
printf("%d\n",dp[f][v]);
}
return ;
}

Poj-1157-LITTLE SHOP OF FLOWERS的更多相关文章

  1. POJ 1157 LITTLE SHOP OF FLOWERS (超级经典dp,两种解法)

    You want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flo ...

  2. sgu 104 Little shop of flowers 解题报告及测试数据

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB 问题: 你想要将你的 ...

  3. [POJ1157]LITTLE SHOP OF FLOWERS

    [POJ1157]LITTLE SHOP OF FLOWERS 试题描述 You want to arrange the window of your flower shop in a most pl ...

  4. SGU 104. Little shop of flowers (DP)

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...

  5. POJ-1157 LITTLE SHOP OF FLOWERS(动态规划)

    LITTLE SHOP OF FLOWERS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19877 Accepted: 91 ...

  6. 快速切题 sgu104. Little shop of flowers DP 难度:0

    104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB PROBLEM Yo ...

  7. poj1157LITTLE SHOP OF FLOWERS

    Description You want to arrange the window of your flower shop in a most pleasant way. You have F bu ...

  8. POJ1157 LITTLE SHOP OF FLOWERS DP

    题目 http://poj.org/problem?id=1157 题目大意 有f个花,k个瓶子,每一个花放每一个瓶子都有一个特定的美学值,问美学值最大是多少.注意,i号花不能出如今某大于i号花后面. ...

  9. [CH5E02] A Little Shop of Flowers

    问题描述 You want to arrange the window of your flower shop in a most pleasant way. You have F bunches o ...

  10. 【POJ - 3262】Protecting the Flowers(贪心)

    Protecting the Flowers 直接中文 Descriptions FJ去砍树,然后和平时一样留了 N (2 ≤ N ≤ 100,000)头牛吃草.当他回来的时候,他发现奶牛们正在津津有 ...

随机推荐

  1. Flex加载google地图、百度地图以及天地图作底图

    一  Flex加载Google地图作底图 (1)帮助类GoogleLayer.as /* * 根据输入的地图类型加载Google地图(by chenyuming) */ package Layers ...

  2. 如何设置a标签的宽高,如何使a标签的文字垂直居中

    通常情况下a标签是没有宽高的,设置 width 和 height 没有作用. 若要使用 width 和 height,需要把a标签转为块级元素,即:display:block|inline-block ...

  3. C# 或 Asp.net 2.0 邮件发送模块(亲测)

    using System.Net.Mail;using System.Net; public class Mail    {        MailMessage mm;        SmtpCli ...

  4. object-assign合并对象

    1. Object.assign() 对于合并对象操作, ECMAScript 6 中提供了一个函数: Object.assign(target, source); 这个方法会将所有可枚举 [1] 的 ...

  5. ORA-01704: string literal too long

    update mkt_page_links set longdescription = ' {some html text > 4000 char} ' where menuidno = 310 ...

  6. SQLServer 命令批量删除数据库中指定表(游标循环删除)

    DECLARE @tablename VARCHAR(30),@sql VARCHAR(500)DECLARE cur_delete_table CURSOR READ_ONLY FORWARD_ON ...

  7. VS2008中调试dll

    1.运行dll实例时,会直接弹出一个小框: 选择可拉起这个dll的exe运行就可以调试了 2.以后每次都会直接运行了,要重新选择程序,弹出上面的框,需要在project-->debugging- ...

  8. struts2各个jar包的作用

    ---------------------------------------------------struts2核心jar包------------------------------------ ...

  9. SAP无损耗,FP前台和回写均有2%损耗

    SAP前台显示无损耗 FP前台显示有损耗 回写也有损耗 检查:从SAP取数到FP表是没有损耗 1132物料编码的主数据也是没有损耗 检查:FP_MO2SAP存储过程

  10. php protobuff 使用

    http://hi.baidu.com/sing520/item/a6e98a3545fe1ef2e6bb7ad0 php 不支持uint32 不支持空结构 不支持package