/*cubic maximum contiguous subsequence sum algorithm *int maxsubsum const vector int maxsum forint size)++ forint ij size)++ int thissum forint ik < ++ thissum +ak ]ifthissum maxsum maxsum thissumreturn maxsumfigure algorithm it turns out that more precise analysistaking into account the actual size of these loopsshows that the answer is ( and that our estimate above was factor of too high (which is all rightbecause constants do not matterthis is generally true in these  -  kinds of problems the precise analysis is obtained from the sum - = = = which tells how many times line is executed the sum can be evaluated inside outusing formulas from section in particularwe will use the formulas for the sum of the first integers and first squares first we have = - + = next we evaluate - = ( ( )( this sum is computed by observing that it is just the sum of the first integers to complete the calculationwe evaluate