246282026-02-13 08:37:26szjMaximális szorzat (50 pont)cpp17Wrong answer 6/5059ms2740 KiB
#include <bits/stdc++.h>
#define ll long long
#define blugy %1000000007
using namespace std;
class cucc
{
public:
    bool operator()(const ll &x, const ll &y)const
    {
        return x < y;
    }
};
int main()
{
    //ifstream cin("f.txt");
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n, k, b, i, a, sum=1, parsum=0, el;
    cin >> n >> k >> b;
    priority_queue<ll, vector<ll>, cucc> nega;
    priority_queue<ll, vector<ll>, greater<ll>> pozi;
    for(i=0; i<n; i++)
    {
        cin >> a;
        if(a<0)nega.push(a);
        else pozi.push(a);
    }
    while(nega.size()>b)
    {
        k+=nega.top();
        nega.pop();
        pozi.push(0);
    }
    if(k<0)
    {
        cout << -1;
        return 0;
    }
    if(pozi.empty())
    {
        while(!nega.empty())
        {
            pozi.push(nega.top());
            nega.pop();
        }
    }
    if(!pozi.empty())
    {
        while(k!=0)
        {
            a = pozi.top();
            pozi.pop();
            pozi.push(a+1);
            k--;
        }
    }

    while(!pozi.empty())
    {
        sum=(sum*(abs(pozi.top())blugy))blugy;
        pozi.pop();
    }
    while(!nega.empty())
    {
        sum=(sum*(abs(nega.top()))blugy)blugy;
        nega.pop();
    }
    cout << -1;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/01ms316 KiB
4Wrong answer0/01ms316 KiB
5Wrong answer0/04ms568 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/24ms632 KiB
11Wrong answer0/241ms1456 KiB
12Wrong answer0/143ms1456 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/14ms608 KiB
15Accepted1/18ms884 KiB
16Wrong answer0/126ms1088 KiB
17Accepted1/18ms964 KiB
18Wrong answer0/16ms952 KiB
19Wrong answer0/156ms2740 KiB
20Wrong answer0/150ms2628 KiB
21Wrong answer0/159ms2732 KiB
22Accepted1/135ms2556 KiB
23Wrong answer0/143ms1344 KiB
24Wrong answer0/143ms1488 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/24ms564 KiB
27Wrong answer0/235ms1492 KiB
28Wrong answer0/135ms1492 KiB
29Accepted2/224ms1012 KiB
30Wrong answer0/135ms1340 KiB
31Accepted1/114ms1508 KiB
32Wrong answer0/22ms316 KiB
33Wrong answer0/235ms1424 KiB
34Wrong answer0/135ms1396 KiB
35Wrong answer0/237ms1452 KiB
36Wrong answer0/235ms1368 KiB
37Wrong answer0/234ms1384 KiB
38Wrong answer0/235ms1548 KiB
39Wrong answer0/12ms428 KiB