题目链接:http://acm.hust.edu.cn/vjudge/contest/124435#problem/I
密码:acm
Sample InputSample Output
分析:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<math.h>
#include<queue>
#include<map>
using namespace std; #define INF 0x3f3f3f3f
#define N 1534 int maps[N][N],dp[N][N]; int main()
{
int n,i,j; scanf("%d", &n); for(i=;i<=n;i++)
for(j=;j<=i;j++)
scanf("%d", &maps[i][j]); for(i=n;i>;i--)
{
for(j=;j<=i;j++)
dp[i][j]=max(dp[i+][j],dp[i+][j+])+maps[i][j];
} printf("%d\n", dp[][]); return ; }