MaxSubsum/olesya | MaxSubsum/irodin | ||||
---|---|---|---|---|---|
n | 1 | elem = int(input()) | n | 1 | cur_num = eval(input()) |
2 | res = elem | 2 | max_sum = cur_num | ||
3 | max_sum = 0 | 3 | cur_sum = 0 | ||
4 | while elem != 0: | ||||
5 | max_sum += elem | ||||
6 | res = max(res, max_sum) | ||||
7 | if max_sum < 0: | ||||
8 | max_sum = 0 | ||||
9 | elem = int(input()) | ||||
10 | print(res) | ||||
11 | 4 | ||||
t | t | 5 | while cur_num != 0: | ||
6 | cur_sum += cur_num | ||||
7 | max_sum = max(max_sum, cur_sum) | ||||
8 | if cur_sum < 0: | ||||
9 | cur_sum = 0 | ||||
10 | cur_num = eval(input()) | ||||
11 | |||||
12 | print(max_sum) | ||||
13 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|