251322026-02-18 08:17:34vyrallMaximális szorzat (50 pont)pypy3Wrong answer 14/50603ms42424 KiB
n, k, b = map(int, input().split())
nums = [int(i) for i in input().split()]
neg = len([i for i in nums if i < 0])
modder = 1000000007

def prod(iterator):
    mult = 1
    for j in iterator:
        mult *= j
    if mult >= 0:
        return mult % modder
    else:
        return -1

if neg < b:
    print(-1)
else:
    if neg % 2 == 1:
        while neg - b != 0:
            idx, mx = max(enumerate([i for i in nums if i < 0]), key=lambda x: x[1])
            nums[idx] = 0
            k += mx
            neg -= 1
    need = [i for i in nums if i >= 0]
    for i in range(k):
        idx, mn = min(enumerate(need), key=lambda x: x[1])
        nums[nums.index(mn)] += 1
        need[idx] += 1

    if k >= 0:
        print(prod(nums))
    else:
        print(-1)
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/043ms19604 KiB
2Accepted0/045ms19628 KiB
3Accepted0/039ms19676 KiB
4Accepted0/037ms19896 KiB
5Wrong answer0/0289ms23016 KiB
6Accepted2/241ms19672 KiB
7Accepted2/252ms21472 KiB
8Accepted2/248ms21564 KiB
9Accepted2/270ms21732 KiB
10Time limit exceeded0/2503ms22604 KiB
11Time limit exceeded0/2602ms38448 KiB
12Time limit exceeded0/1584ms38296 KiB
13Wrong answer0/1103ms21736 KiB
14Time limit exceeded0/1586ms22248 KiB
15Time limit exceeded0/1597ms25664 KiB
16Time limit exceeded0/1588ms33076 KiB
17Runtime error0/182ms26344 KiB
18Accepted1/161ms25072 KiB
19Runtime error0/1101ms34936 KiB
20Runtime error0/1104ms33960 KiB
21Runtime error0/1105ms37040 KiB
22Runtime error0/1101ms33964 KiB
23Time limit exceeded0/1603ms34936 KiB
24Time limit exceeded0/1602ms35436 KiB
25Wrong answer0/259ms21740 KiB
26Wrong answer0/2182ms22456 KiB
27Runtime error0/278ms28880 KiB
28Runtime error0/179ms29028 KiB
29Accepted2/264ms25576 KiB
30Time limit exceeded0/1589ms42424 KiB
31Time limit exceeded0/1603ms41016 KiB
32Accepted2/274ms21480 KiB
33Time limit exceeded0/2603ms42164 KiB
34Time limit exceeded0/1591ms36488 KiB
35Time limit exceeded0/2593ms42168 KiB
36Time limit exceeded0/2603ms42332 KiB
37Time limit exceeded0/2582ms42424 KiB
38Time limit exceeded0/2595ms42424 KiB
39Accepted1/171ms21480 KiB