Меркушев Александр, группа 528 MaxSubsum 342 | Гусейнов Саид Сайпудинович 519/2 MaxSubsum 3155 | ||||
---|---|---|---|---|---|
f | 1 | a = int(input()) | f | 1 | a = int(input()) |
n | 2 | cur_sum = 0 | n | 2 | cur = 0 |
3 | max_sum = a | 3 | max_r = a | ||
4 | while a != 0: | 4 | while a != 0: | ||
n | 5 | cur_sum += a | n | 5 | cur += a |
6 | max_sum = max(max_sum, cur_sum) | 6 | max_r = max(max_r, cur) | ||
7 | if cur_sum < 0: | 7 | if cur <= 0: | ||
8 | cur_sum = 0 | 8 | cur = 0 | ||
9 | a = int(input()) | 9 | a = int(input()) | ||
t | 10 | print(max_sum) | t | 10 | print(max_r) |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|