| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不知道这样可不可以a#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int a[101][101],b[101][101];
int main()
{
int i,j,k;
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(i=1; i<=n; i++)
{
for(j=1; j<=m; j++)
{
scanf("%d",&a[i][j]);
}
}
b[1][1]=a[1][1];
for(k=2; k<=n; k++)
{
b[1][k]=max(a[1][k],b[1][k-1]);
}
for(i=2; i<=n; i++)
{
b[i][i]=b[i-1][i-1]+a[i][i];
for(j=i+1; j<=m; j++)
{
b[i][j]=max(b[i-1][j-1]+a[i][j],b[i][j-1]);
}
}
printf("%d\n",b[n][m]);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator