| ||||||||||
| 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 | |||||||||
求大神看看这个程序怎么能ac呢,我觉得是错的啊#include <iostream>
#include <cstring>
using namespace std;
int value[102][102],dp[102][102];
int main()
{
int F,V;
while(cin>>F>>V)
{
for(int i=0;i<F;++i)
for(int j=0;j<V;++j)
cin>>value[i][j];
dp[0][1]=dp[1][0]=-50;
for(int i=1;i<=F;++i)dp[i][1]=max(value[i-1][0],dp[i-1][1]);
for(int i=1;i<=V;++i)dp[1][i]=max(value[0][i-1],dp[1][i-1]);
for(int i=2;i<=F;++i)
for(int j=2;j<=V;++j)
{
int t=dp[i][j-1];
if(dp[i-1][j-1]+value[i-1][j-1]<0)t=-50000;
dp[i][j]=max(dp[i-1][j-1]+value[i-1][j-1],t);
}
cout<<dp[F][V]<<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