MaxSubsum/abrivan | MaxSubsum/Stephan | ||||
---|---|---|---|---|---|
n | 1 | s = input() | n | 1 | a = input() |
2 | a = eval(s) | 2 | x = eval(a) | ||
3 | suma = 0 | 3 | suma = 0 | ||
n | 4 | max_sum = a | n | 4 | max_sum = x |
5 | if a < 0: | 5 | if x < 0: | ||
6 | zn = False | 6 | y = False | ||
7 | else: | 7 | else: | ||
n | 8 | zn = True | n | 8 | y = True |
9 | while a != 0: | 9 | while x != 0: | ||
10 | suma = suma + a | 10 | suma = suma + x | ||
11 | if suma > max_sum: | 11 | if suma > max_sum: | ||
12 | max_sum = suma | 12 | max_sum = suma | ||
n | 13 | if not zn: | n | 13 | if not y: |
14 | if a < 0: | 14 | if x < 0: | ||
15 | if a > max_sum: | 15 | if x > max_sum: | ||
16 | max_sum = a | 16 | max_sum = x | ||
17 | else: | 17 | else: | ||
n | 18 | zn = True | n | 18 | y = True |
19 | suma = a | 19 | suma = x | ||
20 | if a > max_sum: | 20 | if x > max_sum: | ||
21 | max_sum = a | 21 | max_sum = x | ||
22 | if suma < 0: | 22 | if suma < 0: | ||
23 | suma = 0 | 23 | suma = 0 | ||
t | 24 | s = input() | t | 24 | a = input() |
25 | a = eval(s) | 25 | x = eval(a) | ||
26 | print(max_sum) | 26 | print(max_sum) | ||
27 | 27 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|