| ||||||||||
| 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 | |||||||||
求助 1157#include<iostream>
using namespace std;
int max(int a,int b)
{
if(a>b)
return a;
return b;
}
int main()
{
int map[101][101];
int cost[101][101];
int i,j,k;
int Max;
int N,M;
cin>>N>>M;
for( i=1 ; i<=N ; i++ )
{
for( j=1 ; j<=M ; j++ )
{
cin>>map[i][j];
}
}
memset(cost,0,sizeof(cost));
cost[0][0]=INT_MIN;
Max=INT_MIN;
for(j=1;j<=M;j++)
cost[1][j]=max(cost[1][j-1],map[1][j]);
for( i=2 ; i<=N ; i++ )
for( j=i ; j<=M ; j++ )
{
for( k=i-1 ; k<j;k++)
cost[i][j]=max(cost[i-1][k]+map[i][j],cost[i][j]);
if(i==N)
Max=max(Max,cost[i][j]);
}
cout<<Max<<endl;
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator