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 |
核心代码int findMax(int32_t *src, int32_t *tempSum, int32_t *maxSum, int len) { int i = 0; int j = 0; int k = 0; int index = 0; int temp = 0; int size = len * (len + 1) / 2; int max = maxSum[0]; for (i = 1; i < len; ++i) { index = 0; for (j = 0; j < len; ++j) { temp = 0; for (k = j; k < len; ++k) { temp += src[k * len + i]; tempSum[index] += temp; if (tempSum[index] > maxSum[index]) { maxSum[index] = tempSum[index]; } if (tempSum[index] < 0) { tempSum[index] = 0; } ++index; } } } for (i = 0; i < size; ++i) { if(maxSum[i] > max) { max = maxSum[i]; } } return max; } //i=0的时候,对tempSum和maxSum初始化,全负数也可以过 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator