Posted on 2008-03-24 22:57
superman 阅读(309)
评论(0) 编辑 收藏 引用 所属分类:
ZOJ
1 /* Accepted 1074 C++ 00:00.07 876K */
2 #include <iostream>
3
4 using namespace std;
5
6 int n;
7 int A[101][101];
8
9 int maxSubList(int b[], int n)
10 {
11 int f[101] = {0}, max = 0;
12 for(int i = 1; i <= n; i++)
13 {
14 f[i] = b[i];
15 f[i] >?= f[i - 1] + b[i];
16 max >?= f[i];
17 }
18 return max;
19 }
20
21 int maxSubMatrix()
22 {
23 int max = 0;
24 for(int i = 1; i <= n; i++)
25 {
26 int b[101] = {0};
27 for(int j = i; j <= n; j++)
28 {
29 for(int k = 1; k <= n; k++)
30 b[k] += A[j][k];
31 max >?= maxSubList(b, n);
32 }
33 }
34 return max;
35 }
36
37 int main()
38 {
39 cin >> n;
40 for(int i = 1; i <= n; i++)
41 for(int j = 1; j <= n; j++)
42 cin >> A[i][j];
43 cout << maxSubMatrix() << endl;
44
45 return 0;
46 }
47