void max_sum(int *a, int len, int &low, int &high, int &max)
{
int temp_max = 0;
int temp_sum = 0;
int i = 0;
int temp_l =0, temp_h = 0;
for (; i < len; i++)
{
if (a[i] < 0)
{
if (temp_max > max)
{
low = temp_l;
high = i - 1;
max = temp_max;
}
if (temp_max + a[i] > 0)
{
temp_max += a[i];
}
else
{
temp_max = 0;
temp_l = i + 1;
}
}
else
{
temp_max += a[i];
}
}
temp_max = 0;
for (int i = temp_l; i < len; i++)
{
temp_max += a[i];
}
if(temp_max > max)
{
low = temp_l;
high = len - 1;
max = temp_max;
}
}