155132025-02-20 10:08:58MatematikaMaximális szorzat (50 pont)cpp17Wrong answer 4/5075ms2340 KiB
#include <bits/stdc++.h>

using namespace std;
#define int long long

signed main()
{
    int n,k,m,kezdes=-1,negativ=0; cin >> n >> k >> m;
    vector<int> vec(n);
    for(auto& z:vec)
    {
        cin >> z;
        if(z<0)
            negativ++;
    }
    sort(vec.begin(),vec.end());
    for(int i=0; vec[i]<0 && i<n; i++)
        kezdes=i;
    for(int i=0; i<negativ-m; i++)
    {
        k+=vec[kezdes-i];
        vec[kezdes-i]=0;
    }
    /*for(auto z:vec)
        cerr << z << " ";*/
    if(k<0)
    {
        cout << -1;
        return 0;
    }
    priority_queue<int, vector<int>, greater<int>> pq;
    for(auto& z:vec)
        if(z>=0)
            pq.push(z);
    while(k>0)
    {
        int x=pq.top();
        //cerr << x << "\n";
        pq.pop();
        x++;
        pq.push(x);
        k--;
    }
    int ossz=pq.top();
    pq.pop();
    while(!pq.empty())
    {
        ossz*=pq.top();
        pq.pop();
    }
    for(auto& z:vec)
        if(z<0)
            ossz*=z;
    cout << ossz;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base4/50
1Accepted0/01ms508 KiB
2Accepted0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/04ms564 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/27ms472 KiB
11Wrong answer0/271ms2340 KiB
12Wrong answer0/175ms2340 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/17ms476 KiB
15Accepted1/120ms564 KiB
16Wrong answer0/139ms1056 KiB
17Accepted1/120ms564 KiB
18Accepted1/113ms1200 KiB
19Runtime error0/141ms1192 KiB
20Runtime error0/129ms1196 KiB
21Runtime error0/159ms1196 KiB
22Runtime error0/124ms1076 KiB
23Wrong answer0/174ms1832 KiB
24Wrong answer0/175ms2340 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/24ms316 KiB
27Runtime error0/229ms800 KiB
28Runtime error0/128ms820 KiB
29Wrong answer0/234ms820 KiB
30Wrong answer0/159ms1196 KiB
31Accepted1/143ms1196 KiB
32Wrong answer0/22ms316 KiB
33Wrong answer0/259ms1076 KiB
34Wrong answer0/161ms1076 KiB
35Wrong answer0/263ms1076 KiB
36Wrong answer0/259ms1268 KiB
37Wrong answer0/259ms1268 KiB
38Wrong answer0/259ms1076 KiB
39Wrong answer0/12ms316 KiB