Nyoj 234 吃土豆
来源:互联网 发布:linux设置pxe启动 编辑:程序博客网 时间:2024/04/30 06:30
/**#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 510;int MAX(int a, int b){return a > b ? a : b;}int main(){int row, col;int Graph[MAXN][MAXN];int dp[MAXN];int i, j;while (~scanf("%d %d", &row, &col)){memset(Graph, 0, sizeof(Graph));memset(dp, 0, sizeof(dp));for (i = 3; i < row+3; ++i){for (j = 3; j < col+3; ++j){scanf("%d", &Graph[i][j]);Graph[i][j] += MAX(Graph[i][j-2], Graph[i][j-3]) ;}}for (i = 3; i < row + 3; ++i){dp[i] += MAX(dp[i-2], dp[i-3]) + MAX(Graph[i][col+1], Graph[i][col+2]);}cout<<dp[row+2]<<endl;}return 0;}*/#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 510;int MAX(int a, int b){return a > b ? a : b;}int main(){int row, col;int Graph[MAXN][MAXN];int dp[MAXN];int i, j;while (~scanf("%d %d", &row, &col)){memset(Graph, 0, sizeof(Graph));memset(dp, 0, sizeof(dp));for (i = 3; i < row+3; ++i){for (j = 3; j < col+3; ++j){ scanf("%d", &Graph[i][j]);Graph[i][j] += MAX(Graph[i][j-2], Graph[i][j-3]);//在第i行从第0个位置到第j个位置可以吃到最多的土豆,跟第i行j-2,j-3两列有关}dp[i] = MAX(dp[i-2], dp[i-3]) + MAX(Graph[i][col+1], Graph[i][col+2]);}printf("%d\n",dp[row+2]);}return 0;}
0 0
- nyoj 234 吃土豆
- Nyoj 234 吃土豆
- nyoj 234 吃土豆
- NYOJ-234-DP(吃土豆)
- NYOJ 题目234 吃土豆
- nyoj-234-吃土豆(动态规划)
- nyoj-动态规划-234-吃土豆-201308131021
- nyoj 吃土豆 234 (双层DP)
- NYOJ 吃土豆(动态规划)
- hdu-Beans(动态规划,nyoj-234-吃土豆)
- 题目234 吃土豆
- 吃土豆
- 吃土豆
- 吃土豆
- 吃土豆
- 吃土豆
- 吃土豆
- NY--234 -- 吃土豆 [二维动态规划]
- 圆的面积
- div布局-Jquery 收起左栏、全屏、半透明div遮盖照片、半透明div遮盖全屏弹出窗口
- LVS架构设计
- 第一个iOS应用——泽化计算器(ZiwerCounter)
- C# 3.0介绍 (九)- GroupBy操作
- Nyoj 234 吃土豆
- 蓝桥杯2014年以前JAVA历年真题及答案整理——Excel地址转换
- oracle总结(三)--单行函数
- PJSIP学习笔记——PJSUA层发起呼叫的主要流程
- box-sizing
- response.write()刷新后影响页面排版,可用 this.Page.ClientScript.RegisterStartupScript
- Base SDK和Deployment Target
- 表驱动法应用的难点
- strlen函数实现源码与解析。