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