9 lines
265 B
Python
9 lines
265 B
Python
|
def pgsp2(lst:list):
|
||
|
sommes_max = [lst[0]]
|
||
|
for i in range(1, len(lst)):
|
||
|
if lst[i] > (sommes_max[-1] + lst[i]):
|
||
|
sommes_max.append(lst[i])
|
||
|
else:
|
||
|
sommes_max.append(sommes_max[-1] + lst[i])
|
||
|
return maximum(sommes_max)
|