很水的一个dp

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100;
int a[2*N+5][N+5],dp[2*N+5][N+5];
int main()
{
int T,n,i,j,ca=0;
cin>>T;
while(T--)
{
cin>>n;
memset(a,0,sizeof(a));
memset(dp,0,sizeof(dp));
for( i=1;i<=n;i++)
for(j=1;j<=i;j++)
cin>>a[i][j];
for(i=n+1;i<=2*n-1;i++)
for(j=1;j<=2*n-i;j++)
cin>>a[i][j];
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+a[i][j];
}
for(i=n+1;i<=2*n-1;i++)
{
for(j=1;j<=2*n-i;j++)
dp[i][j]=max(dp[i-1][j],dp[i-1][j+1])+a[i][j];
}
ca++;
cout<<"Case "<<ca<<": "<<dp[2*n-1][1]<<endl;
}
return 0;
}

lightoj 1004的更多相关文章

  1. Monkey Banana Problem LightOJ - 1004

    Monkey Banana Problem LightOJ - 1004 错误记录: 1.数组开小2.每组数据数组没有清空 #include<cstdio> #include<cst ...

  2. lightoj 1004 dp:数字三角形

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1004 #include <cstdio> #include <cst ...

  3. Lightoj 1004 - Monkey Banana Problem

    题目链接:http://acm.hust.edu.cn/vjudge/contest/121396#problem/F http://lightoj.com/volume_showproblem.ph ...

  4. (LightOJ 1004) Monkey Banana Problem 简单dp

    You are in the world of mathematics to solve the great "Monkey Banana Problem". It states ...

  5. lightoj刷题日记

    提高自己的实力, 也为了证明, 开始板刷lightoj,每天题量>=1: 题目的类型会在这边说明,具体见分页博客: SUM=54; 1000 Greetings from LightOJ [简单 ...

  6. 区间DP LightOJ 1422 Halloween Costumes

    http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...

  7. bzoj 1004 Cards

    1004: [HNOI2008]Cards Description 小春现在很清闲,面对书桌上的N张牌,他决定给每张染色,目前小春只有3种颜色:红色,蓝色,绿色.他询问Sun有 多少种染色方案,Sun ...

  8. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  9. LightOj 1298 - One Theorem, One Year(DP + 欧拉)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1298 题意:给你两个数 n, p,表示一个数是由前 k 个素数组成的,共有 n 个素数 ...

随机推荐

  1. npm:Node.js的软件包管理器

    npm https://www.npmjs.com/ 2016-08-03

  2. python正则实例

    # -*- coding: cp936 -*-import reidcardregex=r"^[1-9]\d{14}(\d{2}[0-9x])?$"print re.search( ...

  3. PHP 向 MySql 中数据修改操作时,只对数字操作有效,非数字操作无效,怎么办?

    问题描述:   用PHP向MySql数据库中修改数据,实现增删改(数据库能正确连接) 经测试,代码只能对数字进行正常的增删改操作,非数字操作无效   但要在课程名称中输入中文,应该如果修改呢?   存 ...

  4. 在Windows Server 2008上部署SVN代码管理总结

    这段时间在公司开发Flex程序,所以使用TortoiseSVN作为团队代码管理器,今天在公司服务器上部署SVN服务器,并实验成功,总结如下: 服务器环境: 操作系统:Windows Server 20 ...

  5. 与wait for a undo record相关的系统卡死

    今天下班之前同事过来找我寻求帮助,说是某客户的ORACEL数据库服务器从昨天起就开始很奇怪,一个语句执行很慢很慢,好像整个系统都卡住了.      问题1:请问最近应用系统有更新过程序吗?答:没有更新 ...

  6. ubuntu中文版切换为英文后字体变化问题解决

    为了熟悉更多Linux 的英语词汇,希望把Ubuntu 的界面换成英文的.使用System->Administration->Language Suport( 系统-> 管理-> ...

  7. javascript随手记

    编码规范 避免使用全局变量 写在所有函数外面的变量就是全局变量. 之所以要避免使用全局变量是因为:如果有多个类库的话,它们都定义了一个名字的变量.这时候后引入的类库中该变量的值就会覆盖前面引入的类库中 ...

  8. IIS Handler and Module探索

    Create Handler & Module Run the Visual Studio Create a Class Library “HMHandler” --> Change t ...

  9. 实现strlen,strcpy,strcat,strcmp同功能的函数stringLength,stringCopy,stringCatch,stringCompare

    #import <Foundation/Foundation.h> /* 求字符串长度 */ int stringLength(char arr[]); /* 复制字符串 将arr1 复制 ...

  10. Linux下 config/configure/Configure、make 、make test/make check、sudo make install 的作用

    转自Linux下 config/configure/Configure.make .make test/make check.sudo make install 的作用 这些都是典型的使用GNU的AU ...