149782025-02-10 16:02:51antiMaximális szorzat (50 pont)cpp17Wrong answer 6/5059ms792 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] + 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
2Accepted0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/04ms412 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/24ms440 KiB
11Wrong answer0/252ms792 KiB
12Wrong answer0/156ms700 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/14ms508 KiB
15Accepted1/120ms500 KiB
16Wrong answer0/121ms564 KiB
17Accepted1/120ms484 KiB
18Accepted1/110ms536 KiB
19Wrong answer0/141ms564 KiB
20Wrong answer0/130ms572 KiB
21Wrong answer0/159ms740 KiB
22Wrong answer0/125ms784 KiB
23Wrong answer0/159ms768 KiB
24Wrong answer0/156ms784 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/24ms316 KiB
27Wrong answer0/230ms584 KiB
28Wrong answer0/130ms528 KiB
29Accepted2/223ms540 KiB
30Wrong answer0/159ms564 KiB
31Accepted1/141ms564 KiB
32Wrong answer0/22ms404 KiB
33Wrong answer0/259ms712 KiB
34Wrong answer0/159ms712 KiB
35Wrong answer0/259ms564 KiB
36Wrong answer0/259ms780 KiB
37Wrong answer0/259ms556 KiB
38Wrong answer0/259ms564 KiB
39Wrong answer0/11ms316 KiB