152372025-02-17 12:28:24tamasnagyMaximális szorzat (50 pont)cpp17Time limit exceeded 1/50600ms748 KiB
#include <iostream>
using namespace std;
int a[100001];

int minkeres(int n) {
    int mini = a[0];
    int minin = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < mini) {
            mini = a[i];
            minin = i;
        }
    }
    return minin;
}
int minkeres0(int n) {
    int mini = 1000000000;
    int minin = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] < mini && a[i]>=0) {
            mini = a[i];
            minin = i;
        }
    }
    return minin;
}
int main()
{
    int n, k, b;
    cin >> n >> k >> b;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int db=0;
    for (int i = 0; i < n; i++) {
        if (a[i] < 0) {
            db++;
        }
    }
    while (b < db) {
        int minindex=minkeres(n);
        k -= abs(a[minindex]);
        a[minindex] = 0;
        db--;
    }
    while (k) {
        int x = minkeres0(n);
        k--;
        a[x]++;
    }
    int s=1;
    for (int i = 0; i < n; i++) {
        s *= a[i];
    }
    if (db > b+1) {
        cout << -1;
    }
    else cout << s;

}
SubtaskSumTestVerdictTimeMemory
base1/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Time limit exceeded0/0598ms440 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/23ms352 KiB
10Wrong answer0/2195ms440 KiB
11Time limit exceeded0/2598ms748 KiB
12Time limit exceeded0/1600ms644 KiB
13Time limit exceeded0/1584ms316 KiB
14Time limit exceeded0/1587ms316 KiB
15Time limit exceeded0/1600ms440 KiB
16Time limit exceeded0/1600ms472 KiB
17Time limit exceeded0/1582ms564 KiB
18Accepted1/18ms564 KiB
19Time limit exceeded0/1600ms564 KiB
20Time limit exceeded0/1600ms568 KiB
21Time limit exceeded0/1598ms728 KiB
22Time limit exceeded0/1574ms564 KiB
23Time limit exceeded0/1587ms592 KiB
24Time limit exceeded0/1592ms560 KiB
25Wrong answer0/24ms316 KiB
26Time limit exceeded0/2600ms416 KiB
27Time limit exceeded0/2578ms564 KiB
28Time limit exceeded0/1584ms564 KiB
29Time limit exceeded0/2587ms564 KiB
30Time limit exceeded0/1600ms564 KiB
31Time limit exceeded0/1578ms748 KiB
32Wrong answer0/2200ms316 KiB
33Time limit exceeded0/2583ms564 KiB
34Time limit exceeded0/1600ms700 KiB
35Time limit exceeded0/2578ms564 KiB
36Time limit exceeded0/2600ms564 KiB
37Time limit exceeded0/2589ms560 KiB
38Time limit exceeded0/2578ms564 KiB
39Wrong answer0/120ms316 KiB