109852024-04-29 18:27:37radocziaronMaximális szorzat (50 pont)python3Runtime error 2/50588ms36400 KiB
n,k,b = map(int,input().split())
lista = list(map(int,input().split()))
i = b
lista.sort()

while i != n and lista[i] <= 0:
    k = k - (abs(lista[i])+1)
    lista[i] += abs(lista[i])+1
    i += 1

i = 0

while i != n and lista[i] < 0:
    i+= 1

if i+1 < b: 
    print(-1) 
else:
    i = b
    c = 1

    if k < 1:
        for i in range(n):
            c = c*lista[i]
    else:
        while k > 0:
            lista[i] += 1
            k -= 1
            if i+1 == n:
                i = b
            else:
                i += 1
        for i in range(n):
            c = c*lista[i]

    print(c)
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/017ms11180 KiB
2Accepted0/018ms11484 KiB
3Accepted0/017ms12016 KiB
4Accepted0/017ms12080 KiB
5Runtime error0/039ms14336 KiB
6Wrong answer0/217ms12704 KiB
7Wrong answer0/217ms12652 KiB
8Wrong answer0/218ms12460 KiB
9Wrong answer0/219ms12736 KiB
10Runtime error0/271ms15116 KiB
11Time limit exceeded0/2568ms16412 KiB
12Time limit exceeded0/1560ms16376 KiB
13Wrong answer0/120ms13128 KiB
14Runtime error0/171ms15388 KiB
15Time limit exceeded0/1555ms11208 KiB
16Time limit exceeded0/1564ms11408 KiB
17Time limit exceeded0/1577ms11428 KiB
18Wrong answer0/174ms15180 KiB
19Runtime error0/1104ms36400 KiB
20Runtime error0/193ms35960 KiB
21Runtime error0/1107ms35256 KiB
22Runtime error0/172ms29616 KiB
23Time limit exceeded0/1556ms17036 KiB
24Time limit exceeded0/1588ms17056 KiB
25Wrong answer0/230ms13488 KiB
26Runtime error0/265ms15692 KiB
27Runtime error0/261ms24432 KiB
28Runtime error0/159ms24508 KiB
29Accepted2/256ms25768 KiB
30Time limit exceeded0/1566ms18076 KiB
31Time limit exceeded0/1551ms18404 KiB
32Wrong answer0/2101ms14428 KiB
33Time limit exceeded0/2564ms17836 KiB
34Time limit exceeded0/1584ms17964 KiB
35Time limit exceeded0/2577ms17992 KiB
36Time limit exceeded0/2560ms17968 KiB
37Time limit exceeded0/2584ms18112 KiB
38Time limit exceeded0/2555ms18100 KiB
39Wrong answer0/193ms14268 KiB