MaxSubsum/warnachinka | MaxSubsum/disfavour | ||||
---|---|---|---|---|---|
n | 1 | x = int(input()) | n | 1 | a = int(input()) |
2 | sm, mxsm = 0, 0 | 2 | sum, maxsum = 0, 0 | ||
3 | ng = -100500 | 3 | neg = -9999999999 | ||
4 | while x: | 4 | while a: | ||
5 | sm += x | 5 | sum += a | ||
6 | if mxsm < sm: | 6 | if maxsum < sum: | ||
7 | mxsm = sm | 7 | maxsum = sum | ||
8 | elif sm < 0: | 8 | elif sum < 0: | ||
9 | sm = 0 | 9 | sum = 0 | ||
10 | 10 | ||||
n | 11 | if x < 0 and x > ng: | n | 11 | if a < 0 and a > neg: |
12 | ng = x | 12 | neg = a | ||
13 | x = int(input()) | 13 | a = int(input()) | ||
14 | if mxsm != 0: | 14 | if maxsum != 0: | ||
15 | print(mxsm) | 15 | print(maxsum) | ||
16 | else: | 16 | else: | ||
t | 17 | print(ng) | t | 17 | print(neg) |
18 | 18 |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|