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