from SoSe24.algodat.foundation import AlgoDatArray, AlgoDatValue, read_int_sequence, MinusInf from time import perf_counter as pfc def maxfolge2(z: AlgoDatArray) -> (int, int, int): maximum = AlgoDatValue(MinusInf()) current_sum = AlgoDatValue(0) left = AlgoDatValue(0) right = AlgoDatValue(0) for i in range(z.size): current_sum.value = 0 for j in range(i, z.size): current_sum += z[j] if current_sum > maximum: maximum.value = current_sum.value left.value = i right.value = j return maximum.value, left, right if __name__ == "__main__": z = read_int_sequence("../../seq0.txt") start = pfc() print(maxfolge2(z)) print(f"Dauer: {pfc() - start:.4f}s") AlgoDatValue.summary()