98452024-03-11 20:24:21birozsMaximális szorzat (50 pont)python3Wrong answer 22/50266ms36848 KiB
N,K,b = map(int,input().split())
lista = list(map(int,input().split()))
negativ = []
pozitiv = []
nulla = 0
for szam in lista:
    if szam < 0:
        negativ.append(szam)
    elif szam > 0:
        pozitiv.append(szam)
    else:
        nulla += 1
negativ.sort(reverse=True)
hatar = abs(sum(negativ[0:len(negativ)-b]))
if  hatar > K:
    print(-1)
elif hatar <= K and hatar + len(negativ) - b > K:
    print(0)
else:
    K = K - (hatar + len(negativ) - b)
    if nulla > K:
        print(0)
    else:
        for i in range(len(negativ) - b + nulla):
            pozitiv.append(1)
        K = K - nulla
        n = len(pozitiv)
        pozitiv.sort()
        while K > 0:
            j = 0
            elso = pozitiv[0]
            while j < n and pozitiv[j] == elso and K > 0:
                pozitiv[j] += 1
                K = K - 1
                j += 1
        szorzat = 1
        for szam in pozitiv:
            szorzat = (szorzat * szam) % (10**9+7)
        for i in range(b):
            szorzat = (szorzat * negativ[i]) % (10**9+7)
        print(szorzat)


        

SubtaskSumTestVerdictTimeMemory
base22/50
1Accepted0/017ms11600 KiB
2Accepted0/018ms11864 KiB
3Accepted0/017ms12112 KiB
4Accepted0/017ms12484 KiB
5Wrong answer0/028ms14652 KiB
6Accepted2/217ms12396 KiB
7Accepted2/217ms12812 KiB
8Accepted2/217ms12588 KiB
9Accepted2/219ms13036 KiB
10Accepted2/237ms15332 KiB
11Accepted2/2229ms34720 KiB
12Accepted1/1231ms34624 KiB
13Wrong answer0/120ms13460 KiB
14Wrong answer0/146ms15528 KiB
15Accepted1/148ms25084 KiB
16Wrong answer0/1167ms24680 KiB
17Accepted1/157ms24928 KiB
18Accepted1/137ms14892 KiB
19Runtime error0/193ms36440 KiB
20Runtime error0/182ms35504 KiB
21Runtime error0/197ms35192 KiB
22Runtime error0/165ms29468 KiB
23Accepted1/1247ms35632 KiB
24Accepted1/1254ms34852 KiB
25Wrong answer0/232ms13364 KiB
26Wrong answer0/232ms15924 KiB
27Runtime error0/256ms24296 KiB
28Runtime error0/156ms24196 KiB
29Accepted2/256ms25488 KiB
30Wrong answer0/1266ms36104 KiB
31Accepted1/168ms36848 KiB
32Wrong answer0/2150ms13932 KiB
33Wrong answer0/2254ms36088 KiB
34Accepted1/1261ms36028 KiB
35Wrong answer0/2252ms36032 KiB
36Wrong answer0/2254ms36244 KiB
37Wrong answer0/2252ms35800 KiB
38Wrong answer0/2266ms36052 KiB
39Wrong answer0/1153ms13740 KiB