| ||||||||||
| 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 | |||||||||
竟然忘了Max有负值⊙﹏⊙贴AC代码#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int a[105][105] = {0},dp[105][105] = {0};
int main()
{
int i,j,n,m,k,Max = -0xfffffff;
while(cin>>n>>m)
{
memset(dp,0,sizeof(dp));
for(i = 1;i <= n;i ++)
for(j = 1;j <= m;j ++)
scanf("%d",&a[i][j]);
for(i = 1;i <= n;i ++)
{
for(j = i;j <= m + i - n;j ++)
{
for(k = i - 1;k < j;k ++)
if(dp[i][j] < dp[i-1][k] + a[i][j] || dp[i][j] == 0)
dp[i][j] = dp[i-1][k] + a[i][j];
}
}
Max = -0xfffffff;
for(i = n;i <= m;i ++)
Max = max(Max,dp[n][i]);
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