MaxSubsum/avakiri | MaxSubsum/kabaczek | ||||
---|---|---|---|---|---|
n | 1 | max_sum = current_sum = int(input()) | n | 1 | max_sum = cur_sum = int(input()) |
2 | 2 | ||||
n | 3 | current_element = int(input()) | n | 3 | cur = int(input()) |
4 | while current_element: | 4 | while cur: | ||
5 | if current_sum < 0: | 5 | if cur_sum < 0: | ||
6 | current_sum = current_element | 6 | cur_sum = cur | ||
7 | else: | 7 | else: | ||
n | 8 | current_sum += current_element | n | 8 | cur_sum += cur |
9 | 9 | ||||
n | 10 | if current_sum > max_sum: | n | 10 | if cur_sum > max_sum: |
11 | max_sum = current_sum | 11 | max_sum = cur_sum | ||
12 | 12 | ||||
t | 13 | current_element = int(input()) | t | 13 | cur = int(input()) |
14 | 14 | ||||
15 | print(max_sum) | 15 | print(max_sum) | ||
16 | 16 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|