Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

竟然忘了Max有负值⊙﹏⊙贴AC代码

Posted by ACMore_txj at 2014-03-29 13:33:30 on Problem 1157
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator