116512024-11-03 17:04:48MagyarKendeSZLGMaximális szorzat (50 pont)cpp17Wrong answer 2/5063ms1512 KiB
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
using ll = long long;

int main() {
    ll N, K, B;
    cin >> N >> K >> B;

    vector<ll> neg, pos;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        if (x < 0) {
            neg.push_back(x);
        } else {
            pos.push_back(x);
        }
    }

    if (neg.size() < B) {
        cout << "-1\n";
        exit(0);
    }

    sort(neg.rbegin(), neg.rend());
    ll result = 1;
    for (int i = 0; i < B; i++) {
        result *= neg.back();
        neg.pop_back();
    }

    exit(0);

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i = 0; i < pos.size(); i++) {
        pq.push(pos[i]);
    }
    for (int i = 0; i < neg.size(); i++) {
        pq.push(neg[i]);
    }

    for (int i = 0; i < K; i++) {
        int mn = pq.top();
        pq.pop();
        pq.push(mn + 1);
    }

    while (!pq.empty()) {
        int mn = pq.top();
        if (mn < 0) {
            cout << "-1\n";
            exit(0);
        }
        pq.pop();
        result *= mn;
    }

    cout << result << "\n";
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/01ms320 KiB
2Wrong answer0/01ms320 KiB
3Wrong answer0/01ms320 KiB
4Wrong answer0/01ms320 KiB
5Wrong answer0/03ms320 KiB
6Wrong answer0/21ms320 KiB
7Wrong answer0/21ms320 KiB
8Wrong answer0/21ms320 KiB
9Wrong answer0/21ms320 KiB
10Wrong answer0/24ms568 KiB
11Wrong answer0/245ms1456 KiB
12Wrong answer0/150ms1368 KiB
13Wrong answer0/11ms320 KiB
14Wrong answer0/14ms568 KiB
15Wrong answer0/119ms900 KiB
16Wrong answer0/121ms1060 KiB
17Wrong answer0/123ms948 KiB
18Wrong answer0/110ms948 KiB
19Wrong answer0/143ms1452 KiB
20Wrong answer0/132ms1456 KiB
21Wrong answer0/163ms1452 KiB
22Wrong answer0/126ms1324 KiB
23Wrong answer0/157ms1120 KiB
24Wrong answer0/150ms1512 KiB
25Wrong answer0/21ms320 KiB
26Wrong answer0/24ms520 KiB
27Wrong answer0/230ms1060 KiB
28Wrong answer0/132ms832 KiB
29Accepted2/218ms988 KiB
30Wrong answer0/163ms1316 KiB
31Wrong answer0/135ms1452 KiB
32Wrong answer0/21ms320 KiB
33Wrong answer0/261ms1456 KiB
34Wrong answer0/161ms1472 KiB
35Wrong answer0/263ms1400 KiB
36Wrong answer0/263ms1500 KiB
37Wrong answer0/261ms1460 KiB
38Wrong answer0/263ms1500 KiB
39Wrong answer0/11ms320 KiB