POJ1157 LITTLE SHOP OF FLOWERS DP
题目
http://poj.org/problem?id=1157
题目大意
有f个花,k个瓶子,每一个花放每一个瓶子都有一个特定的美学值,问美学值最大是多少.注意,i号花不能出如今某大于i号花后面.问最大美学值是多少
解题思路
dp[i][j]表示将第i个花插入第k个瓶子的最大美学值.
状态转移方程为dp[i][j] = max(dp[i-1][(i-1)~(k-f+i-1)]) + value[i][j]
代码
#include <cstdio>
const int maxn = 110;
int f,k;
int v[maxn][maxn];
int dp[maxn][maxn];
int main()
{
scanf("%d%d",&f,&k);
for(int i = 1 ; i <= f ; i ++) {
for(int j = 1 ; j <= k ; j ++) scanf("%d",&v[i][j]);
}
for(int i = 1 ; i <= k-f+1 ; i ++) dp[1][i] = v[1][i];
//dp
for(int i = 2; i <= f ; i ++) {
for(int j = i ; j <= k-f+i ; j ++) {
int ma = -100000000;
for(int kk = i-1 ; kk < j ; kk ++) {
if(ma < dp[i-1][kk]) ma = dp[i-1][kk];
}
dp[i][j] = ma+v[i][j];
}
}
int ma = -10000000;
for(int i = f ; i <= k ; i ++) if(ma < dp[f][i]) ma = dp[f][i];
printf("%d\n",ma);
return 0;
}
POJ1157 LITTLE SHOP OF FLOWERS DP的更多相关文章
- [POJ1157]LITTLE SHOP OF FLOWERS
[POJ1157]LITTLE SHOP OF FLOWERS 试题描述 You want to arrange the window of your flower shop in a most pl ...
- POJ-1157 LITTLE SHOP OF FLOWERS(动态规划)
LITTLE SHOP OF FLOWERS Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19877 Accepted: 91 ...
- 快速切题 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 ...
- 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 ...
- sgu 104 Little shop of flowers 解题报告及测试数据
104. Little shop of flowers time limit per test: 0.25 sec. memory limit per test: 4096 KB 问题: 你想要将你的 ...
- 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 ...
- Little shop of flowers - SGU 104 (DP)
题目大意:把 M 朵花插入 N 个花瓶中,每个花插入不同的花瓶都有一个价值A[Mi][Nj],要使所有的花都插入花瓶,求出来最大的总价值(花瓶为空时价值是0). 分析:dp[i][j]表示前i朵花插入 ...
- SGU 104 Little shop of flowers【DP】
浪(吃)了一天,水道题冷静冷静.... 题目链接: http://acm.sgu.ru/problem.php?contest=0&problem=104 题意: 给定每朵花放在每个花盆的值, ...
- 题解 【POJ1157】LITTLE SHOP OF FLOWERS
先把题目意思说一下: 你有F束花,编号为\(1\)~\(F\)(\(1<=F<=100\)),\(V\)个花瓶,编号为\(1\) ~\(V\)(\(1<=V<=100\)), ...
随机推荐
- android alipay
"java.security.spec.InvalidKeySpecException" KeyFactory keyFactory =KeyFactory.getInstance ...
- 【Cmd】那些年,我们迷恋的cmd命令(二)
那些年,我们迷恋的命令(一) 那些年,我们迷恋的命令(二) Linux系统下基本命令 Linux系统下基本命令: 要区分大小写 uname 显示版本信息(同win2K的 ver) dir 显示当前目录 ...
- Quo JS多种触摸手势轻量级JavaScript库
http://www.uedsc.com/quo-js.html http://quojs.tapquo.com/
- web spring 容器
使用spring的web应用时,不用手动创建spring容器,而是通过配置文件声明式地创建spring容器,因此,在web应用中创建spring容器有如下两种方式: 一.直接在web.xml文件中配置 ...
- maven 引入仓库外部jar
<dependency> <groupId>cn.com.do1</groupId> <artifactId>dqdp-template</art ...
- Spring boot 报错 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
在实际开发中修改别人的代码,发现了这个报错,后来发现是因为pom.xml里面 只要将注释掉的部分注释掉就好了.
- RedHat 将应用程序添加到 Gnome 菜单中
. . . . . 在RedHat下面安装了Eclipse,是解压缩就能运行的,没有经过脚本安装所以无法自动在菜单中生成链接,但是可以通过手动的方式,步骤如下. 首先在/usr/share/appli ...
- Sublime Text2/3怎样在Mac OSX中配置CTags插件
参考地址: http://jingyan.baidu.com/article/48206aeafba820216ad6b3f5.html
- HTTP 响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding
Tomcat 中响应头信息(Http Response Header) Content-Length 和 Transfer-Encoding 客户端(PC浏览器或者手机浏览器)在接受到Tomcat的响 ...
- centos7安装elasticsearch5.2.2
这篇文章比较初级,介绍的是centos7下elasticsearch的安装. 主要阅读对象是初级运维.初级大数据工程师.java工程师.想了解es的.net工程师以及所有感兴趣的朋友. 文章的目的是为 ...