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

第 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. JavaScript 面向对象与原型

    ECMAScript有两种开发模式:1.函数式(过程化);2.面向对象(OOP); 一 创建对象1.普通的创建对象 ? 1 2 3 4 5 6 7 8 9 // 创建一个对象,然后给这个对象新的属性和 ...

  2. SQLServer日志无法收缩原因分析及解决

    SQL Server中的事务日志无疑是SQL Server中最重要的部分之一.因为SQL SERVER利用事务日志来确保持久性(Durability)和事务回滚(Rollback).从而还部分确保了事 ...

  3. JAVA基础_字符串、访问属性

    1.字符串   String s = new String(“123”)不如String s = “123”效率高.   字符串连接操作StringBuilder效率比较高.   StringBuff ...

  4. 借助 MySQLTuner 优化 MySQL 性能(转载的一篇文章)

    MySQLTuner 是一个 Perl 脚本,可以用来分析您的 MySQL 性能,并且基于收集到的信息给出相应的优化建议.这样子,您就可以调整 my.cnf 从而优化您的 MySQL 设置. 这边只是 ...

  5. XidianOJ 1177 Counting Stars

    题目描述 "But baby, I've been, I've been praying hard,     Said, no more counting dollars     We'll ...

  6. JQuery 公网 CDN

    JQuery 公网 CDN   <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js&quo ...

  7. XGBoost参数调优完全指南(附Python代码)

    XGBoost参数调优完全指南(附Python代码):http://www.2cto.com/kf/201607/528771.html https://www.zhihu.com/question/ ...

  8. android_Activity之Button_OnClickListener

    今天我们要讲的主要是四大组件之一Activity 什么是Android 的四大组件呢?接下来简单了解下. 1.Activity  Activity就是我们应用程序的界面,主要用来跟我们的用户进行交互的 ...

  9. C++中四种转换类型的区别

    一.四种转换类型比较: 类型转换有c风格的,当然还有c++风格的.c风格的转换的格式很简单(TYPE)EXPRESSION,但是c风格的类型转换有不少的缺点,有的时候用c风格的转换是不合适的,因为它可 ...

  10. [转载] 1. JebAPI 之 jeb.api

    本文转载自: https://www.zybuluo.com/oro-oro/note/142707 JEB API 官方地址:https://www.pnfsoftware.com/apidoc/  ...