189182025-11-12 17:03:14KristófMaximális szorzat (50 pont)cpp17Wrong answer 6/5076ms2140 KiB
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

long long mod=1000000007;


int main()
{
    int n,k,b;
    cin>>n>>k>>b;
    priority_queue<int> negativ,poz;
    int x;
    for(int i=0;i<n;i++)
        {
        cin>>x;
        if(x>-1)
            {
            poz.push(x*-1);
            }
        else
            {
            negativ.push(x);
            }
        }
    if(negativ.size()<b)
        {
        cout<<-1;
        return 0;
        }
    if(negativ.size() == b)
        {
        while(k--)
            {
            x=poz.top()*-1;poz.pop();
            poz.push((x+1)*-1);
            }
        }
    else
        {
        while(negativ.size()!=b)
            {
            k+=negativ.top();
            poz.push(0);
            negativ.pop();
            }
        if(k<0)
            {
            cout<<-1;
            return 0;
            }
        while(k--)
            {
            x=poz.top()*-1;poz.pop();
            poz.push((x+1)*-1);
            }
        }


    long long ans=1;
    while(!poz.empty())
        {

        ans*=(poz.top()*-1)% mod;poz.pop();
        }
    while(!negativ.empty())
        {
        ans*=negativ.top() % mod;negativ.pop();
        }
    cout<<ans;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/01ms316 KiB
2Accepted0/01ms508 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/04ms416 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/22ms316 KiB
10Wrong answer0/27ms564 KiB
11Wrong answer0/270ms1636 KiB
12Wrong answer0/175ms1788 KiB
13Wrong answer0/12ms316 KiB
14Wrong answer0/17ms316 KiB
15Accepted1/117ms820 KiB
16Wrong answer0/139ms1072 KiB
17Accepted1/117ms932 KiB
18Accepted1/113ms792 KiB
19Runtime error0/135ms1404 KiB
20Runtime error0/127ms1412 KiB
21Runtime error0/152ms2140 KiB
22Runtime error0/123ms1308 KiB
23Wrong answer0/176ms1792 KiB
24Wrong answer0/175ms1708 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/26ms564 KiB
27Runtime error0/227ms1268 KiB
28Runtime error0/127ms1316 KiB
29Accepted2/219ms1004 KiB
30Wrong answer0/168ms1776 KiB
31Accepted1/135ms1572 KiB
32Wrong answer0/23ms316 KiB
33Wrong answer0/268ms1784 KiB
34Wrong answer0/168ms1964 KiB
35Wrong answer0/271ms1964 KiB
36Wrong answer0/268ms1840 KiB
37Wrong answer0/268ms1956 KiB
38Wrong answer0/270ms1964 KiB
39Wrong answer0/12ms316 KiB