251312026-02-18 07:49:48vyrallMaximális szorzat (50 pont)pypy3Wrong answer 11/50602ms40708 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
    return mult % modder

if neg < b:
    print(-1)
else:
    if neg % 2 == 0:
        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
    else:
        for i in range(k):
            idx, mn = min(enumerate(nums), key=lambda x: x[1])
            if mn + k - i <= 0:
                idx, _ = max(enumerate(nums), key=lambda x: x[1])
            nums[idx] += 1

    print(prod(nums))
SubtaskSumTestVerdictTimeMemory
base11/50
1Accepted0/039ms19688 KiB
2Accepted0/039ms19460 KiB
3Accepted0/043ms19512 KiB
4Accepted0/043ms19596 KiB
5Wrong answer0/0158ms22504 KiB
6Accepted2/239ms19692 KiB
7Accepted2/254ms21564 KiB
8Accepted2/252ms21392 KiB
9Accepted2/259ms21732 KiB
10Time limit exceeded0/2503ms22484 KiB
11Time limit exceeded0/2602ms38468 KiB
12Time limit exceeded0/1584ms38196 KiB
13Wrong answer0/1114ms21992 KiB
14Time limit exceeded0/1587ms22248 KiB
15Time limit exceeded0/1584ms25580 KiB
16Time limit exceeded0/1578ms25476 KiB
17Runtime error0/192ms26348 KiB
18Accepted1/154ms25060 KiB
19Runtime error0/189ms35028 KiB
20Runtime error0/1101ms34148 KiB
21Runtime error0/192ms37036 KiB
22Runtime error0/1103ms33960 KiB
23Time limit exceeded0/1587ms34920 KiB
24Time limit exceeded0/1587ms35528 KiB
25Wrong answer0/259ms21896 KiB
26Wrong answer0/2393ms22248 KiB
27Runtime error0/290ms29036 KiB
28Runtime error0/187ms29076 KiB
29Accepted2/264ms25576 KiB
30Time limit exceeded0/1589ms36280 KiB
31Time limit exceeded0/1587ms40708 KiB
32Wrong answer0/2363ms21992 KiB
33Time limit exceeded0/2578ms36280 KiB
34Time limit exceeded0/1587ms36536 KiB
35Time limit exceeded0/2597ms36276 KiB
36Time limit exceeded0/2589ms36280 KiB
37Time limit exceeded0/2591ms36296 KiB
38Time limit exceeded0/2588ms36280 KiB
39Wrong answer0/1104ms21736 KiB