MaxSubsum/irodin | MaxSubsum/olesya | ||||
---|---|---|---|---|---|
n | 1 | cur_num = eval(input()) | n | 1 | elem = int(input()) |
2 | max_sum = cur_num | 2 | res = elem | ||
3 | cur_sum = 0 | 3 | max_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) | ||||
4 | 11 | ||||
t | 5 | while cur_num != 0: | t | ||
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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|