149772025-02-10 15:59:44antiMaximális szorzat (50 pont)cpp17Wrong answer 6/5057ms784 KiB
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int n, k, b;
    cin >> n >> k >> b;
    int t[n];
    for(int i=0; i<n; i++){
        cin >> t[i];
    }
    sort(t, t+n);

    if(b%2 == 0){
        int i=b, neg = 0, meg = 1;
        bool fos = false;
        while(k>0){
            t[i]++;
            k--;
            if((t[i] == t[i+1] || t[i] == t[i+1] + 1) && i!=n-1){
                i++;
            }else{
                i=b;
            }
        }
        for(int i=0; i<n; i++){
            if(t[i]<0){
                neg++;
            }
            meg *= t[i];
        }
        if(neg!=b){
            cout << -1;
        }else{
            cout << meg % 1000000007;
        }
    }else{
        int ossz = 0;
        for(int i=b; i<n; i++){
            if(t[i]<0){
                ossz -= t[i];
            }
        }
        if(ossz>k){
            cout << -1;
        }else{
            cout << 0;
        }
    }

}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/04ms376 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms396 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/24ms420 KiB
11Wrong answer0/252ms612 KiB
12Wrong answer0/154ms752 KiB
13Wrong answer0/11ms500 KiB
14Wrong answer0/14ms500 KiB
15Accepted1/120ms588 KiB
16Wrong answer0/121ms532 KiB
17Accepted1/120ms500 KiB
18Accepted1/19ms668 KiB
19Wrong answer0/141ms568 KiB
20Wrong answer0/129ms600 KiB
21Wrong answer0/157ms784 KiB
22Wrong answer0/124ms772 KiB
23Wrong answer0/157ms556 KiB
24Wrong answer0/154ms708 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/24ms316 KiB
27Wrong answer0/228ms508 KiB
28Wrong answer0/128ms408 KiB
29Accepted2/223ms488 KiB
30Wrong answer0/157ms736 KiB
31Accepted1/141ms564 KiB
32Wrong answer0/22ms316 KiB
33Wrong answer0/257ms564 KiB
34Wrong answer0/157ms564 KiB
35Wrong answer0/257ms564 KiB
36Wrong answer0/257ms704 KiB
37Wrong answer0/257ms568 KiB
38Wrong answer0/257ms668 KiB
39Wrong answer0/11ms316 KiB