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

第 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. Contos7 装bcm4312无线网卡驱动

    本次装网卡比较的无语,报错网上竟然找不到答案,误打误撞给装好了,做下记录以后可能会用的上. 首先去官网下载网卡驱动:http://www.broadcom.com/support/802.11 我系统 ...

  2. linux 修改ssh端口号

    vi /etc/ssh/sshd_config 找到#Port 22一段,这里是标识默认使用22端口,修改为如下:  代码如下 复制代码 Port 22 Port 50000 然后保存退出 执行/et ...

  3. ajax XML

    <script src="jquery-1.11.2.min.js"></script> </head> <body> <se ...

  4. java中Thread的 interrupt异常处理

    http://blog.csdn.net/srzhz/article/details/6804756

  5. 在linux上使用交换文件扩展交换空间

    想像一种情景,当我们的Linux系统用尽交换空间时,在这种情况下,我们想要使用swap分区扩展交换空间,但在某些情况下磁盘上已经没有可用的空闲分区了,致使我们不能把它扩大. 因此,在这种情况下,我们可 ...

  6. AX2012 DMF数据导入的问题

    由于AX2012的数据结构比较复杂,通过Excel直接导入表的方式很多数据已经难以导入,比如物料信息,2009只需要导入InventTable,InventTableModule和InventItem ...

  7. LinQ 基础

    LinQ全名:Linq to Sql,是一种数据库访问技术 常见的数据库访问技术: 1.ADO.NET 2.Entity Framework  框架 3.LinQ LinQ是高集成化的数据访问类,它会 ...

  8. HTML、CSS小知识--兼容IE的下拉选择框select

    HTML <div class="s_h_ie"> <select id="Select1" disabled="disabled& ...

  9. UzysAssetsPickerController中文化

    self.labelSelectedMedia.text = NSLocalizedStringFromTable(@"Choose a media", @"UzysAs ...

  10. Sum All Odd Fibonacci Numbers

    function sumFibs(num) { //return num; var arr = [1,1]; var add = 2; while(true){ var item = arr[0] + ...