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 |
WA的要死人了,帮忙看看#include<iostream> using namespace std; int main() { int **dp; int m,n,i,j,k,a,max; cin>>m>>n; dp=new int *[m+2]; for(i=0;i<m+2;i++) dp[i]=new int[n+2]; for(i=0;i<n;i++) { cin>>a; dp[0][i]=a; } for(i=1;i<m;i++) { for(j=0;j<n;j++) { cin>>a; max=-9999999; for(k=0;k<j;k++) { if(dp[i-1][k]>max) max=dp[i-1][k]; } if(max!=-9999999) dp[i][j]=max+a; else dp[i][j]=a; } } max=-9999999; for(i=m-1;i<n;i++) { if(dp[m-1][i]>max) max=dp[m-1][i]; } cout<<max<<endl; //for(i=0;i<m;i++) //{ for(j=0;j<n;j++) // cout<<dp[i][j]<<" "; // cout<<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