HDU 2845 Beans(dp)
来源:互联网 发布:远程监控软件 编辑:程序博客网 时间:2024/05/16 06:43
这题目思路是对的,但是自己写死活写不对,代码太粗糙了,在网上看到这个代码很有技巧性,就贴过来了。
思路是想出来了,但编码技巧还得提高啊,细节处理实在太差了。
//// main.cpp// Richard//// Created by 邵金杰 on 16/9/13.// Copyright © 2016年 邵金杰. All rights reserved.//#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=200000+10;int dp1[maxn],dp2[maxn];int main(){ int n,m; while(scanf("%d%d",&n,&m)!=EOF) { memset(dp1,0,sizeof(dp1)); memset(dp2,0,sizeof(dp2)); int s; for(int i=2;i<=n+1;i++){ for(int j=2;j<=m+1;j++){ scanf("%d",&s); dp1[j]=max(dp1[j-1],dp1[j-2]+s); } dp2[i]=max(dp2[i-1],dp2[i-2]+dp1[m+1]); } cout<<dp2[n+1]<<endl; } return 0;}
0 0
- hdu 2845 Beans(dp)
- hdu 2845 Beans(dp)
- HDU 2845 Beans (DP)
- HDU 2845 Beans(dp)
- HDU-2845 Beans(DP)
- HDU 2845 Beans(dp)
- HDU 2845 Beans (DP)
- HDU 2845 DP Beans
- hdu 2845 Beans (DP)
- HDU 2845 Beans DP
- hdu 2845 Beans dp
- HDU 2845 Beans DP -
- hdu 2845 Beans(二次DP)
- HDU-2845-Beans(简单DP)
- HDU-2845 Beans(两次线性dp)
- hdu 2845 Beans--二维DP
- HDU 2845 Beans 行列dp
- HDU-2845-Beans-简单dp
- 占位
- 占位
- 占位
- 占位
- 占位
- HDU 2845 Beans(dp)
- c++使用thread类时编译出错,对‘pthread_create’未定义的引用
- 占位
- linux设备驱动程序之时钟管理
- 每次进步一点点——Spark 中的宽依赖和窄依赖
- 占位
- 占位
- 占位
- 占位