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 |
N^3都能16MS……囧#include<iostream> using namespace std; #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b)) const int MAXN = 120; const int inf = 0x7f7f7f7f; int n,a[MAXN][MAXN],dp[MAXN]; int main() { while(scanf("%d",&n)!=EOF) { for(int i=1;n-i>=0;i++) { for(int j=1;n-j>=0;j++) { scanf("%d",&a[i][j]); } } int ans=-inf; for(int i=1;n-i>=0;i++) { memset(dp,0,sizeof(dp)); for(int j=i;n-j>=0;j++) { for(int k=1;n-k>=0;k++) dp[k]+=a[j][k]; int t=0; for(int k=1;n-k>=0;k++) { t+=dp[k]; ans=max(t,ans); t=max(t,0); } } } printf("%d\n",ans); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator