Submission details
Task:Maximum sum
Sender:aalto26cm_038
Submission time:2026-09-14 16:40:53 +0300
Language:Python3 (PyPy3)
Status:READY
Result:
Test results
testverdicttime
#10.04 sdetails
#20.04 sdetails
#30.04 sdetails
#40.04 sdetails
#50.04 sdetails
#60.10 sdetails
#70.09 sdetails
#80.12 sdetails
#90.12 sdetails
#100.13 sdetails
#110.04 sdetails
#120.04 sdetails
#130.04 sdetails
#140.04 sdetails
#150.04 sdetails

Code

n = int(input())
arr = list(map(int, input().split()))

opt = [max(arr[0], 0)]
for i in range(1, n):
    opt.append(max(opt[i - 1] + arr[i], 0, arr[i]))

print(opt)
print(max(opt))

Test details

Test 1

Verdict:

input
10
1 1 1 1 1 1 1 1 1 1

correct output
10

user output
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10...

Feedback: Output is longer than expected

Test 2

Verdict:

input
10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1

correct output
-1

user output
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
0

Feedback: Output is longer than expected

Test 3

Verdict:

input
10
24 7 -27 17 -67 65 -23 58 85 -...

correct output
185

user output
[24, 31, 4, 21, 0, 65, 42, 100...

Feedback: Output is longer than expected

Test 4

Verdict:

input
10
99 -59 31 83 -79 64 -20 -87 40...

correct output
154

user output
[99, 40, 71, 154, 75, 139, 119...

Feedback: Output is longer than expected

Test 5

Verdict:

input
10
-19 61 60 33 67 19 -8 92 59 -3...

correct output
383

user output
[0, 61, 121, 154, 221, 240, 23...

Feedback: Output is longer than expected

Test 6

Verdict:

input
200000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

correct output
200000

user output
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10...

Feedback: Output is longer than expected

Test 7

Verdict:

input
200000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

correct output
-1

user output
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...

Feedback: Output is longer than expected

Test 8

Verdict:

input
200000
381082742 830199996 -85684827 ...

correct output
231210956017

user output
[381082742, 1211282738, 112559...

Feedback: Output is longer than expected

Test 9

Verdict:

input
200000
-935928962 -795492223 75287481...

correct output
184607318819

user output
[0, 0, 752874819, 1286768867, ...

Feedback: Output is longer than expected

Test 10

Verdict:

input
200000
524408131 613017181 -62281009 ...

correct output
360019999220

user output
[524408131, 1137425312, 107514...

Feedback: Output is longer than expected

Test 11

Verdict:

input
1
1

correct output
1

user output
[1]
1

Feedback: Output is longer than expected

Test 12

Verdict:

input
1
-2

correct output
-2

user output
[0]
0

Feedback: Output is longer than expected

Test 13

Verdict:

input
5
-1 -1 -1 -1 -2

correct output
-1

user output
[0, 0, 0, 0, 0]
0

Feedback: Output is longer than expected

Test 14

Verdict:

input
2
-3 -2

correct output
-2

user output
[0, 0]
0

Feedback: Output is longer than expected

Test 15

Verdict:

input
1
-1000000000

correct output
-1000000000

user output
[0]
0

Feedback: Output is longer than expected