98502024-03-11 23:43:3342Maximális szorzat (50 pont)python3Wrong answer 6/5059ms36928 KiB
# O(NlogN)
from sys import stdin, stdout
input=stdin.readline
mod=10**9+7

def solv():
    N,K,b = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    print(-1)
    return
    Aplus=[]
    Aminus=[]
    for a in A:
        if a<0:
            Aminus.append(a)
        else:
            Aplus.append(a)
    if len(Aminus)<b:
        print(-1)
        return
    Aminus.sort(reverse=True)
    #print(Aminus,K,b)
    for i in range(len(Aminus)-b):
        K+=Aminus[i]
    if K<0:
        print(-1)
        return
    prod=1
    for i in range(len(Aminus)-b,len(Aminus)):
        prod*=-Aminus[i]
        prod%=mod
    if len(Aplus)==0:
        if len(Aminus)==b:
            print(-1)
            return
    for i in range(len(Aminus)-b):
        Aplus.append(0)
    Aplus.sort()
    Aplus.append(10**10)
    i=0
    while K>0:
        if i==0:
            Aplus[0]+=1
            K-=1
            i+=1
        else:
            if Aplus[i-1]>Aplus[i]:
                Aplus[i]+=1
                K-=1
                i+=1
            else:
                i=0
    #print(K,Aplus,prod)
    for i in range(len(Aplus)-1):
        prod*=Aplus[i]
        prod%=mod
    print(prod)
    
solv()

SubtaskSumTestVerdictTimeMemory
base6/50
1Wrong answer0/017ms11508 KiB
2Wrong answer0/017ms11976 KiB
3Wrong answer0/017ms12076 KiB
4Wrong answer0/017ms12524 KiB
5Wrong answer0/020ms14200 KiB
6Wrong answer0/217ms12420 KiB
7Wrong answer0/218ms12656 KiB
8Wrong answer0/217ms12768 KiB
9Wrong answer0/218ms13224 KiB
10Wrong answer0/221ms15548 KiB
11Wrong answer0/257ms34992 KiB
12Wrong answer0/157ms35440 KiB
13Wrong answer0/118ms13696 KiB
14Wrong answer0/121ms16044 KiB
15Accepted1/135ms25244 KiB
16Wrong answer0/135ms25208 KiB
17Accepted1/135ms25060 KiB
18Wrong answer0/128ms15452 KiB
19Wrong answer0/154ms35724 KiB
20Wrong answer0/150ms36448 KiB
21Wrong answer0/152ms35868 KiB
22Accepted1/148ms30464 KiB
23Wrong answer0/159ms35836 KiB
24Wrong answer0/157ms35968 KiB
25Wrong answer0/217ms14076 KiB
26Wrong answer0/221ms16452 KiB
27Wrong answer0/237ms24892 KiB
28Wrong answer0/137ms25068 KiB
29Accepted2/237ms25920 KiB
30Wrong answer0/157ms36748 KiB
31Accepted1/154ms36168 KiB
32Wrong answer0/218ms14556 KiB
33Wrong answer0/257ms36864 KiB
34Wrong answer0/156ms36928 KiB
35Wrong answer0/257ms36884 KiB
36Wrong answer0/257ms36740 KiB
37Wrong answer0/254ms36832 KiB
38Wrong answer0/257ms36680 KiB
39Wrong answer0/118ms14444 KiB