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

大虾看看,实在找不出有错了。3x~~

Posted by 15452812 at 2005-11-09 16:27:02 on Problem 1157
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main()
{
	int F,V,i,j,k;
	cin>>F>>V;
	vector<vector<int> > bunch,value;
	value.resize(F);

	bunch.resize(F);
	for(i=0; i<F; ++i){
		bunch[i].resize(V);
		value[i].resize(V);
		for(j=0; j<V; ++j)
			cin>>bunch[i][j];
	}
	int max(0),tmp(0);

	value[0][0] = bunch[0][0];
	for(i=1; i<V; ++i)
		value[0][i] = value[0][i-1]>bunch[0][i]?value[0][i-1]:bunch[0][i];

	copy(value[0].begin(),value[0].end(),ostream_iterator<int>(cout," "));
	cout<<endl;

	for(i=1; i<F; ++i) {//
		for(j=i; j<=V+i-F; ++j){//value[i][j] is 前i束排在前j个位置的最大值
		max=0;
			for(k=i-1; k<j; ++k)
				max = max>value[i-1][k]?max:value[i-1][k];
			value[i][j] = max+bunch[i][j];
			copy(value[i].begin(),value[i].end(),ostream_iterator<int>(cout," "));
			cout<<endl;
		}
	}
	max=0;
	for(i=F-1; i<V; ++i)
		max = value[F-1][i]>max?value[F-1][i]:max;
	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