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 |
Re:额,我这是错的,晕死,航电过不了,poj竟然能过,我又改了一下,现在对了In Reply To:哇,一ac了,我转换成一维来做的 Posted by:TSERROF at 2012-10-22 15:18:47 都能过了 #include<iostream> #include <cstring> using namespace std; int matrix[105][105],dp[105][105],len[105];//表情前i行j列的最大矩阵的和 #define INF -9999999; int main() { int n; while(cin>>n) { for(int i=0;i<n;++i) for(int j=0;j<n;++j) cin>>matrix[i][j]; int sum=0,maxsum=0; for(int s=0;s<n-1;++s) { for(int h=1;h<=n && h+s<=n;++h) { fill(len,len+105,0); for(int j=0;j<n;++j) { for(int i=s;i<h+s;++i) { len[j]+=matrix[i][j]; } } sum=0; int max_p=0; for(int k=0;k<n;++k) { sum+=len[k]; if(len[k]>max_p)max_p=len[k]; if(sum>maxsum)maxsum=sum; if(sum<0)sum=0; } if(maxsum==0)maxsum=max_p; if(max_p>maxsum)maxsum=max_p; } } cout<<maxsum<<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