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

1157就是通不过,但我坚信我的程序没错!奇怪

Posted by linbzh at 2008-09-09 15:59:19 and last updated at 2008-09-09 16:48:39
#include<iostream>
using namespace std;
int n, m;//行、列
int s[101][101];
int dp[101][101];
void init(){
	//freopen("in.txt","r", stdin);
	cin>>n>>m;
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin>>s[i][j];
			dp[0][j] = s[0][j];
		}
	}
}
int work(){
	for(int i=1; i<n; i++){
		for(int j=i; j<m-n+i+1; j++){
			for(int k=i-1; k<j; k++){
				if(s[i][j]+dp[i-1][k] > dp[i][j])
					dp[i][j] = s[i][j]+dp[i-1][k];
			}
		}
	}
	int sum;
	for(int j=n-1; j<m; j++){
		if(sum < dp[n-1][j]) sum = dp[n-1][j];
	}
	return sum;
}
int main(){
	init();
	cout<<work()<<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