| ||||||||||
| 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 | |||||||||
大虾看看,实在找不出有错了。3x~~#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator