152902025-02-18 08:54:18gyarturMaximális szorzat (50 pont)cpp17Wrong answer 1/50600ms792 KiB
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int x[100000];
int n, k, b;
int drbNegativ;

void Beolvas(){
    cin>>n>>k>>b;
    for(int i = 0; i < n; i++)cin>>x[i];
}

int Negativdrb(){
    int drb = 0;
    for(int i = 0; i < n; i++){
        if(x[i] < 0)drb++;
    }
    return drb;
}

void Lepes(){
    if(drbNegativ > b){
        int *a = upper_bound(x, x+n, 0)-1;
        ++*a;
        if(*a >= 0)drbNegativ--;
        while(*a > *(a+1) && a != x+n-1){
            swap(*a,*(a+1));
            a++;
        }
        return;
    }
    int *a = upper_bound(x, x+n, -1);
    ++*a;
    while(*a > *(a+1) && a != x+n-1){
        swap(*a,*(a+1));
        a++;
    }
}

int main(){
    Beolvas();
    sort(x, x+n);
    drbNegativ = Negativdrb();
    while(k > 0){
        Lepes();
        k--;
    }
    int p = 1;
    for(int i = 0; i < n; i++){
        p *= x[i];
    }
    cout<<p;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms508 KiB
5Wrong answer0/07ms448 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms508 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms404 KiB
10Wrong answer0/26ms500 KiB
11Wrong answer0/261ms792 KiB
12Wrong answer0/163ms732 KiB
13Wrong answer0/14ms316 KiB
14Wrong answer0/112ms316 KiB
15Wrong answer0/154ms604 KiB
16Wrong answer0/1109ms460 KiB
17Wrong answer0/194ms600 KiB
18Accepted1/110ms600 KiB
19Wrong answer0/178ms692 KiB
20Wrong answer0/167ms616 KiB
21Wrong answer0/196ms564 KiB
22Wrong answer0/161ms564 KiB
23Wrong answer0/165ms604 KiB
24Wrong answer0/164ms732 KiB
25Wrong answer0/22ms512 KiB
26Wrong answer0/26ms316 KiB
27Time limit exceeded0/2600ms752 KiB
28Time limit exceeded0/1600ms564 KiB
29Wrong answer0/271ms596 KiB
30Wrong answer0/165ms716 KiB
31Wrong answer0/143ms608 KiB
32Wrong answer0/24ms316 KiB
33Wrong answer0/265ms608 KiB
34Wrong answer0/167ms564 KiB
35Wrong answer0/267ms564 KiB
36Wrong answer0/267ms564 KiB
37Wrong answer0/268ms564 KiB
38Wrong answer0/265ms564 KiB
39Wrong answer0/14ms316 KiB