134052025-01-07 20:40:17Vkrisztian01Maximális szorzat (50 pont)cpp17Wrong answer 5/5064ms1552 KiB
#include <iostream>
#include<bits/stdc++.h>

using namespace std;
using ll = long long int ;
const ll mod = 1e9 + 7 ;

int main()
{
    ll n , k , b ;
    cin >> n >> k >> b ;

    priority_queue<ll> pq1 ;
    priority_queue<ll , vector<ll> , greater<ll> > pq2 ;

    while(n--)
    {
        ll a ;
        cin >> a ;

        if(a < 0)
            pq1.push(a) ;
        else
            pq2.push(a) ;
    }

    if(pq1.size() < b)
    {
        cout << -1 ;
        return 0 ;
    }

    while(pq1.size() != b)
    {
        k += pq1.top() ;
        pq2.push(0) ;

        pq1.pop() ;
    }

    if(k < 0)
    {
        cout << -1 ;
        return 0 ;
    }

    while(k)
    {
        ll a = pq2.top() ;
        pq2.pop() ;

        ++a ;
        pq2.push(a) ;
        k-- ;
    }

    ll ans = 1 ;
   /* while(!pq1.empty())
    {
        ans *= abs(pq1.top()) ;
        ans %= mod ;
        pq1.pop() ;
    }

    while(!pq2.empty())
    {
        ans *= abs(pq2.top()) ;
        ans %= mod ;
        pq2.pop() ;
    } */

    cout << ans ;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base5/50
1Wrong answer0/01ms512 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/01ms316 KiB
4Wrong answer0/01ms316 KiB
5Wrong answer0/04ms564 KiB
6Wrong answer0/21ms380 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms320 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/26ms564 KiB
11Wrong answer0/254ms1524 KiB
12Wrong answer0/161ms1548 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/16ms564 KiB
15Accepted1/118ms876 KiB
16Wrong answer0/132ms1068 KiB
17Accepted1/118ms832 KiB
18Wrong answer0/19ms944 KiB
19Runtime error0/137ms1452 KiB
20Runtime error0/128ms1332 KiB
21Runtime error0/154ms1540 KiB
22Runtime error0/125ms1452 KiB
23Wrong answer0/164ms1312 KiB
24Wrong answer0/161ms1344 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/24ms564 KiB
27Runtime error0/227ms944 KiB
28Runtime error0/127ms992 KiB
29Accepted2/220ms944 KiB
30Wrong answer0/154ms1452 KiB
31Accepted1/135ms1452 KiB
32Wrong answer0/22ms316 KiB
33Wrong answer0/254ms1460 KiB
34Wrong answer0/156ms1452 KiB
35Wrong answer0/257ms1444 KiB
36Wrong answer0/254ms1552 KiB
37Wrong answer0/254ms1452 KiB
38Wrong answer0/254ms1520 KiB
39Wrong answer0/11ms316 KiB