Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 38914 | Accepted: 20534 |
Description
Input
Output
Sample Input
4 0 -2 -7 0 9 2 -6 2 -4 1 -4 1 -1 8 0 -2
Sample Output
15
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int map[105][105], sum[105][105]; 6 int main(){ 7 int n, maxn; 8 /* freopen("in.c", "r", stdin); */ 9 while(~scanf("%d", &n)){ 10 for(int i = 1;i <=n;i ++){ 11 for(int j = 1;j <= n;j ++){ 12 scanf("%d", &map[i][j]); 13 sum[i][j] = sum[i-1][j] + sum[i][j-1] + map[i][j] - sum[i-1][j-1]; 14 } 15 } 16 maxn = -100000000; 17 for(int i = 1;i <= n;i ++){ 18 for(int j = 1;j <= n;j ++){ 19 for(int k = i+1;k <= n;k ++){ 20 for(int p = j+1;p <= n;p ++) 21 maxn = max(sum[k][p]-sum[k][j-1]-sum[i-1][p] + sum[i-1][j-1], maxn); 22 } 23 } 24 } 25 printf("%d\n", maxn); 26 } 27 return 0; 28 }
POJ ---1050 To the Max,布布扣,bubuko.com
原文:http://www.cnblogs.com/anhuizhiye/p/3618714.html