142482025-01-10 10:33:31balintmarotiMaximális szorzat (50 pont)cpp17Runtime error 41/5059ms1548 KiB
#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    long k;
    long b;
    cin >> n;
    cin >> k;
    cin >> b;

    vector<long> hehe = {};

    int negatives = 0;

    for (int i = 0; i < n; i++) {
        long x;
        cin >> x;

        if (x <= 0) {
            negatives += 1;
        }

        hehe.push_back(x);
    }

    sort(hehe.begin(), hehe.end());

    for (int i = negatives - 1; i >= b; i--) {
        long z = -hehe[i];
        hehe[i] += z;
        k -= z;
    }

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

        int x = b;

        while (k > 0) {
            hehe[x] += 1;
            k -= 1;
            x += 1;
            if (x == n || hehe[x] >= hehe[x - 1]) {
                x = b;
            }
        }

        long f = 1;

        for (int i = 0; i < n; i++) {
            f = (hehe[i] * f) % 1000000007;
        }

        cout << f << endl;
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base41/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted0/01ms500 KiB
4Accepted0/01ms316 KiB
5Accepted0/04ms568 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms316 KiB
10Accepted2/24ms568 KiB
11Accepted2/252ms1532 KiB
12Accepted1/156ms1548 KiB
13Accepted1/11ms316 KiB
14Accepted1/14ms580 KiB
15Accepted1/120ms944 KiB
16Accepted1/123ms1040 KiB
17Accepted1/120ms944 KiB
18Accepted1/110ms944 KiB
19Runtime error0/141ms1456 KiB
20Runtime error0/129ms1432 KiB
21Runtime error0/159ms1440 KiB
22Runtime error0/124ms1452 KiB
23Accepted1/159ms1480 KiB
24Accepted1/157ms1452 KiB
25Accepted2/21ms316 KiB
26Accepted2/24ms564 KiB
27Runtime error0/229ms1028 KiB
28Runtime error0/128ms1012 KiB
29Wrong answer0/224ms820 KiB
30Accepted1/159ms1504 KiB
31Accepted1/143ms1448 KiB
32Accepted2/22ms396 KiB
33Accepted2/259ms1440 KiB
34Accepted1/159ms1452 KiB
35Accepted2/259ms1452 KiB
36Accepted2/259ms1448 KiB
37Accepted2/259ms1316 KiB
38Accepted2/259ms1500 KiB
39Accepted1/11ms316 KiB