CSES - Aalto Competitive Programming 2024 - wk3 - Mon - Results
Submission details
Task:Maximum sum
Sender:Mojojijo
Submission time:2024-09-16 16:40:04 +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.09 sdetails
#70.09 sdetails
#80.11 sdetails
#90.11 sdetails
#100.11 sdetails
#110.04 sdetails
#120.04 sdetails
#130.04 sdetails
#140.05 sdetails
#150.04 sdetails

Code

def maximum_sum(n, array):

    max_sum = float('inf')
    current_sum = 0

    for num in array:
        current_sum = max(num, current_sum + num)
        max_sum = max(max_sum, current_sum)

    return max_sum

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

print(maximum_sum(n, array))

# Input:
# 8
# -1 3 -2 5 3 -5 2 2
# Output:
# 9

Test details

Test 1

Verdict:

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

correct output
10

user output
inf

Test 2

Verdict:

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

correct output
-1

user output
inf

Test 3

Verdict:

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

correct output
185

user output
inf

Test 4

Verdict:

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

correct output
154

user output
inf

Test 5

Verdict:

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

correct output
383

user output
inf

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
inf

Test 7

Verdict:

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

correct output
-1

user output
inf

Test 8

Verdict:

input
200000
381082742 830199996 -85684827 ...

correct output
231210956017

user output
inf

Test 9

Verdict:

input
200000
-935928962 -795492223 75287481...

correct output
184607318819

user output
inf

Test 10

Verdict:

input
200000
524408131 613017181 -62281009 ...

correct output
360019999220

user output
inf

Test 11

Verdict:

input
1
1

correct output
1

user output
inf

Test 12

Verdict:

input
1
-2

correct output
-2

user output
inf

Test 13

Verdict:

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

correct output
-1

user output
inf

Test 14

Verdict:

input
2
-3 -2

correct output
-2

user output
inf

Test 15

Verdict:

input
1
-1000000000

correct output
-1000000000

user output
inf