114762024-10-05 21:28:33madvirMaximális szorzat (50 pont)cpp14Wrong answer 0/50596ms2424 KiB
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int n, k, b;
    cin >> n >> k >> b;
    long long a[n], neg=0, negcard=0, ub=b, n0=0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if(a[i]<0) {
            ub--;
            if(ub<=0) {
                cout << "changing: " << a[i] << " to " << 1 << endl;
                neg=neg-a[i];
                negcard++;
                a[i]=1;
            }
        }
        else {
            if(a[i]==0) {
                n0++;
                a[i]=1;
            }
        }
    }
    if(k>=neg) {
        k=k-neg-negcard;
        if(n0>k) {
            cout << 0;
        }
        else {
            int mini=1;
            k-=n0;
            while(k>0) {
                for(int i=0; i<n && k>0; i++) {
                    if(a[i]==mini) {
                        a[i]++;
                        k--;
                    }
                }
                mini++;
            }
            long long p=1;
            for(int i=0; i<n; i++) {
                p=p*a[i];
            }
            cout << p;
        }
    }
    else {
        cout << -1;
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Accepted0/03ms632 KiB
2Wrong answer0/03ms360 KiB
3Wrong answer0/03ms528 KiB
4Wrong answer0/03ms524 KiB
5Wrong answer0/07ms764 KiB
6Wrong answer0/23ms656 KiB
7Wrong answer0/23ms420 KiB
8Wrong answer0/23ms360 KiB
9Wrong answer0/23ms504 KiB
10Wrong answer0/226ms488 KiB
11Time limit exceeded0/2588ms1968 KiB
12Time limit exceeded0/1591ms2116 KiB
13Wrong answer0/13ms360 KiB
14Wrong answer0/18ms488 KiB
15Wrong answer0/124ms1128 KiB
16Wrong answer0/119ms1000 KiB
17Wrong answer0/125ms1072 KiB
18Wrong answer0/110ms816 KiB
19Time limit exceeded0/1593ms1768 KiB
20Time limit exceeded0/1593ms1580 KiB
21Wrong answer0/154ms2212 KiB
22Time limit exceeded0/1596ms1420 KiB
23Wrong answer0/154ms2280 KiB
24Wrong answer0/150ms2200 KiB
25Wrong answer0/23ms360 KiB
26Wrong answer0/26ms488 KiB
27Wrong answer0/228ms1256 KiB
28Wrong answer0/128ms1384 KiB
29Wrong answer0/271ms1128 KiB
30Wrong answer0/152ms2192 KiB
31Wrong answer0/135ms1568 KiB
32Wrong answer0/2101ms504 KiB
33Wrong answer0/254ms2088 KiB
34Wrong answer0/154ms2152 KiB
35Wrong answer0/254ms2076 KiB
36Wrong answer0/254ms2084 KiB
37Wrong answer0/252ms2152 KiB
38Wrong answer0/254ms2424 KiB
39Wrong answer0/114ms376 KiB