1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <cstdio>
#include "maklib.h"

int main(void){

unsigned long size = Size(); 


    long long b1, b2, e1, max1, max2;
    b1 = e1 = max1 = 0;
    long long i,j,k,sum;
    max1 = max2 = b2 = 0;
	for (i = 1; i <= size; i++) {
		max2 += ElementAt(i);
		if (max2 < 0) {
			max2 = 0;
			b2 = i + 1;	
		} 
		else if (max2 > max1){
			max1 = max2;
			b1 = b2;
			e1 = i;
		}
	}
	printf( "%lld", max1);



return 0;
}