|
|
вернуться в форумcalculate : fmax(n) = max(fmax(n-1)+value(n),value(n)); Why? Consider p1 = 5, p2 = -2 fmax(1) = 5 fmax(2) = max( 5+(-2), -2 ) = 3 But if i = j = 1 fmax(2) = 5 Or I got wrong understanding of the task? F[i] is max values of sequence with the final element is a[i]. Finally, answer will be max( F[1], ... F[n] ). Sorry because of English. It's wrong algorithm and more hard than right. |
|
|