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

第 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. Oracle中快速查询和操作某个用户下的所有表数据信息

    一.禁止所有的外键约束 在pl/sql developer下执行如下语句:SELECT 'ALTER TABLE ' || table_name || ' disable CONSTRAINT ' | ...

  2. 【C#基础】System.Reflection (反射)

    在使用.NET创建的程序或组件时,元数据(metadata)和代码(code)都存储于"自成一体"的单元中,这个单元称为装配件.我们可以在程序运行期间访问这些信息.在System. ...

  3. 2016/12/14---- C3P0

    查询查询一条记录 public UserBean findActiver(String ac) throws SQLException { QueryRunner qr = new QueryRunn ...

  4. redis 问题解决(MISCONF Redis is configured to save RDB snapshots)

    (error) MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on d ...

  5. 你还没成为Delphi QC的成员吗?(转红鱼儿)

    Delphi很早就建立了quality.embarcadero.com,简称为QC,质量控制中心,用来接收用户反馈的bug,新功能建议等,是开发者与delphi官方直接交流的平台.无论是否为正版用户, ...

  6. —linux 磁盘配额按用户管理(quota)

    我根据下面的ref链接整理的基本是的按用户额度管理步骤 (按组的额度管理被简化掉) 我在Ubuntu服务器12.04下整理,其他版本的Ubuntu和Linux应该都没有问题的 (有任何错误都指正给我, ...

  7. Variant OLE automation

    The Variant data type is the data type for all variables. can contain any kind of data except fixed- ...

  8. JavaScript系列:Date对象

    <script type="text/javascript">    var oDate = new Date();    var iYear = oDate.getF ...

  9. Java NIO教程 Buffer

    缓冲区本质上是一块可以写入数据,然后可以从中读取数据的内存,这块内存中有很多可以存储byte(或int.char等)的小单元.这块内存被包装成NIO Buffer对象,并提供了一组方法,用来方便的访问 ...

  10. HDOJ 4508 湫湫系列故事——减肥记I (完全背包带优化)

    完全背包的模版题.. 加了一个小优化  n^2的写法 O(V+N)在本题中复杂度较高 不采纳 完全背包问题有一个很简单有效的优化,是这样的:若两件物品i.j满足c[i]<=c[j]且w[i]&g ...