题目大意:简单说就是求连续序列的最大和, 但是不同的是要输出从第几个开始到第几个结束。
解题思路:只要在分治的时候一起返回最大值的区间就可以了, 但是要注意下连续序列被分割成左右两边时考虑最大求解时候的下标问题。
#include <stdio.h>
#include <string.h>
const int N = 20005;
int maxsum(int *A, int x, int y, int &frist, int &end) {
if (x == y - 1) {
frist = x;
end = y;
return A[x];
}
int cur = x + (y - x) / 2;
int p1, p2, p3, q1, q2, q3, Max, v, L = A[cur - 1], R