HDU 2845 Beans (DP)
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Now, how much qualities can you eat and then get ?
Input
Output
Sample Input
11 0 7 5 13 9
78 4 81 6 22 4
1 40 9 34 16 10
11 22 0 33 39 6
Sample Output
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 200105 int main(void)
{
int n,m;
int max,temp_1,temp_2,ans; while(scanf("%d%d",&n,&m) != EOF)
{
int dp[n + ][m + ]; memset(dp,,sizeof(dp));
for(int i = ;i <= n;i ++)
for(int j = ;j <= m;j ++)
scanf("%d",&dp[i][j]); for(int i = ;i <= n;i ++)
{
max = dp[i][m];
for(int j = m;j >= ;j --)
{
dp[i][j] += dp[i][j + ] > dp[i][j + ] ? dp[i][j + ] : dp[i][j + ];
max = max > dp[i][j] ? max : dp[i][j];
}
dp[i][] = max;
} max = dp[][];
dp[][] += dp[][];
for(int i = ;i <= n;i ++)
{
dp[i][] += dp[i - ][] > dp[i - ][] ? dp[i - ][] : dp[i - ][];
max = max > dp[i][] ? max : dp[i][];
} printf("%d\n",max);
} return ;
}
HDU 2845 Beans (DP)的更多相关文章
- HDU 2845 Beans (两次线性dp)
Beans Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- HDU 2845 Beans (DP)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- hdu 2845——Beans——————【dp】
Beans Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- HDU 2845 Beans(dp)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- HDU 2845 Beans (动态调节)
Beans Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- Hdu 2845 Beans
Beans Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- hdu 2845 Beans 2016-09-12 17:17 23人阅读 评论(0) 收藏
Beans Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- hdu 2845 Beans(最大不连续子序列和)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- hdu 2845简单dp
/*递推公式dp[i]=MAX(dp[i-1],dp[i-2]+a[j])*/ #include<stdio.h> #include<string.h> #define N 2 ...
随机推荐
- Routed Events【pluralsight】
Routing Strategies: Direct Bubbling Tunneling WHy use them? Any UIElement can be a listener Common h ...
- Tomcat设置自己的项目为默认项目(用IP访问的是自己的项目)
方法一:将项目拷贝到webapps下,并更名为ROOT; 方法二:在tomcat/conf/service.xml的<host></host>中配置 <Context p ...
- application与cache
每个项目都有一些全局,常用的信息,而这些信息如果在每次使用时都载入,那必将耗费很大的资源,特别是对访问压力大的系统.因此,这个情况中,把这些全局信息放到缓存中是很必要的,放在缓存中可以使得数据能够很快 ...
- ags js下载地址
https://developers.arcgis.com/en/downloads/ 备用
- Spring aop expression
任意公共方法的执行:execution(public * *(..))任何一个名字以“set”开始的方法的执行:execution(* set*(..))AccountService接口定义的任意方法 ...
- erlang 查看进程相关信息
出自: http://blog.sina.com.cn/s/blog_96b8a1540100zczz.html
- Javascript(JS)对Cookie的读取、删除、写入操作帮助方法
var CookieUtils = { get: function (name) { var cookieName = encodeURIComponent(name) + '=', cookieSt ...
- IAR EWARM Argument variables $PROJ_DIR$ $TOOLKIT_DIR$
在IAR中的help中输入argument variables时会找到这样的一个列表: Argument variables On many of the pages in the Options d ...
- Codeforces Round #140 (Div. 1) D. The table 构造
D. The table 题目连接: http://www.codeforces.com/contest/226/problem/D Description Harry Potter has a di ...
- Codeforces Gym 100231G Voracious Steve 记忆化搜索
Voracious Steve 题目连接: http://codeforces.com/gym/100231/attachments Description 有两个人在玩一个游戏 有一个盆子里面有n个 ...