| ||||||||||
| 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 n;
int dfs(int *c)
{
int d[100];
int i,max=c[0];
d[0]=c[0];
for(i=0;i<n;i++)
{
if(d[i-1]<0) {d[i]=c[i];if(max<d[i])max=d[i];}
else {d[i]=d[i-1]+c[i];if(max<d[i])max=d[i];}
}
return max;
}
int main()
{
freopen("in.txt","r",stdin);
int i,j,a[100][100],k,ll,l,b[100];
cin>>n;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>a[i][j];
ll=a[0][0];
for(i=0;i<n;i++)
b[i]=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
b[j]=0;
for(j=i;j<n;j++)
{
for(k=0;k<n;k++)
{
b[k]+=a[j][k];
// cout<<b[k]<<' ';
}
l=dfs(b);//cout<<" ---"<<l<<endl;
if(l>ll) ll=l;
}
}
cout<<ll<<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