147422025-01-31 10:46:32markfsibianMaximális szorzat (50 pont)cpp17Wrong answer 3/50600ms776 KiB
#include <iostream>
#include <climits>

using namespace std;

int neg, n, up, v[100001];

int main()
{
    cin >> n >> up >> neg;
    int mini = INT_MAX, t, ind, negs = 0, z = 0;
    for (int i = 1; i <= n; ++i)
    {

        cin >> t;
        if (t < 0)
            negs++;
        if (t == 0)
            z++;
        v[i] = t;
    }
    
    
    int negmaxi, negind, f = 0;
    while (negs > neg)
    {
        negmaxi = INT_MIN;
        for (int i = 1; i <= n; ++i)
        {
            if (v[i] > negmaxi && v[i] < 0)
            {
                negind = i;
                negmaxi = v[i];
            }
        }
        v[negind] = v[negind] + up;
        up = 0;
        if (v[negind] - 1 > 0)
        {
            up = v[negind] - 1;
            v[negind] = 1;
        }
        if (v[negind] < 0)
        {
            f = 1;
            break;
        }
        negs--;
        
    }

    if (f)
        cout << -1;
    else
    {

        

        while (z > 0)
        {
            for (int i = 1; i <= n; ++i)
                if (v[i] == 0 && up > 0)
                {
                    v[i] = 1;
                    up--;
                    z--;
                }
            
        }
        

        while (up)
        {
            for (int i = 1; i <= n; ++i)
            {

                if (v[i] < mini && v[i] > 0)
                {
                    mini = v[i];
                    ind = i;
                }
            }
            v[ind]++;
            up--;
            mini++;
            
        }
        
        

        int s = 1;
        for (int i = 1; i <= n; ++i)
            s = s * (v[i] % 1000000000);
        cout << endl << s % 1000000000 + 7<< endl;
    }

}

SubtaskSumTestVerdictTimeMemory
base3/50
1Wrong answer0/01ms508 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/01ms316 KiB
4Wrong answer0/01ms316 KiB
5Wrong answer0/0138ms444 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/24ms316 KiB
10Wrong answer0/2335ms456 KiB
11Time limit exceeded0/2600ms592 KiB
12Time limit exceeded0/1600ms596 KiB
13Wrong answer0/112ms512 KiB
14Time limit exceeded0/1593ms316 KiB
15Accepted1/1333ms564 KiB
16Time limit exceeded0/1583ms564 KiB
17Accepted1/1155ms608 KiB
18Time limit exceeded0/1583ms564 KiB
19Time limit exceeded0/1591ms576 KiB
20Time limit exceeded0/1600ms576 KiB
21Time limit exceeded0/1580ms756 KiB
22Time limit exceeded0/1578ms564 KiB
23Time limit exceeded0/1583ms564 KiB
24Time limit exceeded0/1600ms696 KiB
25Wrong answer0/27ms316 KiB
26Wrong answer0/2254ms500 KiB
27Time limit exceeded0/2578ms564 KiB
28Time limit exceeded0/1587ms564 KiB
29Time limit exceeded0/2600ms564 KiB
30Time limit exceeded0/1578ms576 KiB
31Accepted1/132ms564 KiB
32Wrong answer0/2483ms508 KiB
33Time limit exceeded0/2600ms776 KiB
34Time limit exceeded0/1600ms712 KiB
35Time limit exceeded0/2583ms564 KiB
36Time limit exceeded0/2584ms564 KiB
37Time limit exceeded0/2583ms564 KiB
38Time limit exceeded0/2600ms708 KiB
39Wrong answer0/148ms316 KiB