hdu 2845——Beans——————【dp】
Beans
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3418 Accepted Submission(s): 1629
Now, how much qualities can you eat and then get ?
11 0 7 5 13 9
78 4 81 6 22 4
1 40 9 34 16 10
11 22 0 33 39 6
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
const int maxn=211000;
int a[maxn];
int dp[maxn],d[maxn],dq[maxn];
int mmax(int a,int b,int c){
int ret;
ret=a>b?a:b;
return ret>c?ret:c;
}
int main(){
int n,m;
while(scanf("%d%d",&n,&m)!=EOF){
int i,j,k;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
scanf("%d",&a[j]);
}
dp[0]=0,dp[1]=a[1];
for(j=2;j<=m;j++){
dp[j]=max(dp[j-2]+a[j],dp[j-1]);
}
d[i]=dp[m];
}
dq[1]=d[1];
for(i=2;i<=n;i++){
dq[i]=max(dq[i-1],dq[i-2]+d[i]);
}
printf("%d\n",dq[n]);
}
return 0;
}
hdu 2845——Beans——————【dp】的更多相关文章
- HDU 2845 Beans (DP)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- HDU - 1260 Tickets 【DP】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1260 题意 有N个人来买电影票 因为售票机的限制 可以同时 卖一张票 也可以同时卖两张 卖两张的话 两 ...
- HDU 2845 Beans(dp)
Problem Description Bean-eating is an interesting game, everyone owns an M*N matrix, which is filled ...
- HDOJ_1087_Super Jumping! Jumping! Jumping! 【DP】
HDOJ_1087_Super Jumping! Jumping! Jumping! [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- Kattis - honey【DP】
Kattis - honey[DP] 题意 有一只蜜蜂,在它的蜂房当中,蜂房是正六边形的,然后它要出去,但是它只能走N步,第N步的时候要回到起点,给出N, 求方案总数 思路 用DP 因为N == 14 ...
- HDOJ 1423 Greatest Common Increasing Subsequence 【DP】【最长公共上升子序列】
HDOJ 1423 Greatest Common Increasing Subsequence [DP][最长公共上升子序列] Time Limit: 2000/1000 MS (Java/Othe ...
- HDOJ 1501 Zipper 【DP】【DFS+剪枝】
HDOJ 1501 Zipper [DP][DFS+剪枝] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...
- HDOJ 1257 最少拦截系统 【DP】
HDOJ 1257 最少拦截系统 [DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- HDOJ 1159 Common Subsequence【DP】
HDOJ 1159 Common Subsequence[DP] Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
随机推荐
- 宏定义(无参宏定义和带参宏定义),C语言宏定义详解
1.宏定义说明 宏定义是比较常用的预处理指令,即使用"标识符"来表示"替换列表"中的内容.标识符称为宏名,在预处理过程中,预处理器会把源程序中所有宏名,替换成宏 ...
- Codeforces Round #545 (Div. 2)D(KMP,最长公共前后缀,贪心)
#include<bits/stdc++.h>using namespace std;const int N=1000007;char s1[N],s2[N];int len1,len2; ...
- MyBatis与JDBC的对比
//JDBC的步骤,1.加载驱动.2.获取连接.3.执行sql语句.4.处理结果集.5.关闭资源 Class.forName("com.mysql.jdbc.Driver").ne ...
- 【离散数学】SDUT OJ 指定长度路径数
指定长度路径数 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Problem Description 题目给出一个有n个节点 ...
- 解决vs code中golang插件依赖安装失败问题
解决vs code中golang插件依赖安装失败问题 Installing github.com/nsf/gocode SUCCEEDED Installing github.com/uudashr/ ...
- Unity3d 中 将远程 MySQL 数据库转换为本地 Sqlite
1.创建MySQL2Sqlite脚本mysql2sqlite.sh:(代码地址:https://gist.github.com/esperlu/943776) #!/bin/sh # Converts ...
- How to: Create a Business Model in the XPO Data Model Designer
How to: Create a Business Model in the XPO Data Model Designer This topic provides step-by-step inst ...
- Navicat Premium 12破解激活
下载Navicat Premium 12并安装: 蓝奏云下载:Navicat Premium 12注册机 链接:https://pan.baidu.com/s/1mN-urlh--SX1vbq7h ...
- mysql 面试题
1.一张表,里面有ID自增主键,当insert了17条记录之后,删除了第15,16,17条记录,再把Mysql重启,再insert一条记录,这条记录的ID是18还是15 ? 2.Mysql的技术特 ...
- 扩增子分析QIIME2. 1简介和安装
原网站:https://blog.csdn.net/woodcorpse/article/details/75103929 声明:本文为QIIME2官方帮助文档的中文版,由中科院遗传发育所刘永鑫博士翻 ...