152812025-02-18 08:24:31tamasnagyMaximális szorzat (50 pont)cpp17Wrong answer 0/50600ms920 KiB
#include <iostream>
using namespace std;
int a[100001];
void rendez(int n,int a[]) {
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (a[i] > a[j]) {
                swap(a[i], a[j]);
            }
        }
    }
}
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    rendez(n, a);
    int x = 0;
    while (a[x] < 0) {
        x++;
    }
    if (x > k) {
        while (x > k && m>0) {
            x--;
            m -= abs(a[x]);
            a[x] = 0;
        }
        
    }
    while (m) {
        int i = x+1;
        a[x]++;
        m--;
        while (a[i] < a[x] && m && i<n) {
            a[i]++;
            m--;
            i++;
        }
    }
    int s = 1;
    for (int i = 0; i < n; i++) {
        s *= a[i];
    }
    if (x > k) {
        cout << -1;
    }
    else {
        cout << s;
    }
    

}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/01ms316 KiB
2Accepted0/01ms500 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/090ms444 KiB
6Wrong answer0/21ms532 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/24ms412 KiB
10Wrong answer0/2187ms444 KiB
11Time limit exceeded0/2600ms540 KiB
12Time limit exceeded0/1600ms664 KiB
13Wrong answer0/13ms316 KiB
14Wrong answer0/1246ms316 KiB
15Time limit exceeded0/1582ms564 KiB
16Time limit exceeded0/1578ms564 KiB
17Time limit exceeded0/1589ms468 KiB
18Time limit exceeded0/1600ms564 KiB
19Time limit exceeded0/1579ms564 KiB
20Time limit exceeded0/1583ms580 KiB
21Time limit exceeded0/1583ms716 KiB
22Time limit exceeded0/1600ms564 KiB
23Time limit exceeded0/1586ms920 KiB
24Time limit exceeded0/1580ms564 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/2217ms444 KiB
27Time limit exceeded0/2600ms560 KiB
28Time limit exceeded0/1588ms564 KiB
29Time limit exceeded0/2588ms564 KiB
30Time limit exceeded0/1583ms564 KiB
31Time limit exceeded0/1582ms540 KiB
32Wrong answer0/22ms316 KiB
33Time limit exceeded0/2600ms564 KiB
34Time limit exceeded0/1579ms564 KiB
35Time limit exceeded0/2584ms564 KiB
36Time limit exceeded0/2579ms564 KiB
37Time limit exceeded0/2588ms564 KiB
38Time limit exceeded0/2575ms564 KiB
39Wrong answer0/11ms316 KiB