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 ...
随机推荐
- JS、jqueryie6浏览器下使用js无法提交表单的解决办法
-----------------------JS.jqueryie6浏览器下使用js无法提交表单的解决办法---------------------------------------------- ...
- Release 版本和 Debug 版本
什么是 Release 版本.Debug 版本? bug-缺陷,程序故障.而debug指的是排除缺陷,显然这个模式是面向开发者的. 而release是满足发布所用. Debug 和 Release,在 ...
- iOS开发-关于网络状态的判断
在判断网络状态这个问题上,苹果提供了一个叫Reachability的第三方库,但是这个库并不能真正的检测我们的网络状态,我也是在调试程序的时候发现的.详情可以阅读这个博客http://blog.csd ...
- WinForm设置窗体默认控件焦点
winform窗口打开后文本框的默认焦点设置,进入窗口后默认聚焦到某个文本框,两种方法: ①设置tabindex 把该文本框属性里的tabIndex设为0,焦点就默认在这个文本框里了. ②Winfor ...
- 实战项目:通过当当API将订单抓取到SAP(二)
上一篇博客,我们引用了log4net 这个.这里简单介绍下,为什么引用这个. log4net是记录程序日志信息的,是一个功能著名的开源日志记录组件.利用log4net可以方便地将日志信息记录到文件.控 ...
- iOS开发——高级UI之OC篇&UIdatePicker&UIPickerView简单使用
UIdatePicker&UIPickerView简单使用 /***************************************************************** ...
- Why the framework uses ruby instead of perl?[转]
During the development of the framework, the one recurring question that the Metasploit staff was co ...
- Cocos2d-html5 笔记2: director
今天看了cocos2d-html5代码里面的Director. 最简单的框架 先抛开cocos2d的框架不说,对于一个游戏来说,基本的逻辑框架还是很简单的,首先初始化的时候注册mouse, touch ...
- BigDecimal带精度的运算的两篇文章
转自:http://guoliangqi.iteye.com/blog/670908 之前提到过在商业运算中要使用BigDecimal来进行相关的钱的运算(java中关于浮点运算需要注意的 ),可是实 ...
- 疑难杂症:NoSuchMethodError: com.opensymphony.xwork2.util.finder.UrlSet.includeClassesUrl(Lcom/opensymphony/xwork2/util/finder/ClassLoaderInterface;)
严重: Exception starting filter struts2java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.finde ...