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 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) { 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; for(int k=0;k<n;++k) { sum+=len[k]; if(sum>maxsum)maxsum=sum; if(sum<0)sum=0; } } } 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