149762025-02-10 15:56:09antiMaximális szorzat (50 pont)cpp17Time limit exceeded 4/50600ms780 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;
        while(k>0){
            t[i]++;
            k--;
            if(t[i] == t[i+1] && i!=n-1){
                i++;
            }else{
                i=b;
                sort(t+b, t+n);
            }
        }
        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
base4/50
1Accepted0/01ms500 KiB
2Accepted0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Time limit exceeded0/0600ms408 KiB
6Wrong answer0/21ms380 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms548 KiB
9Wrong answer0/220ms512 KiB
10Wrong answer0/2266ms508 KiB
11Time limit exceeded0/2586ms564 KiB
12Time limit exceeded0/1600ms580 KiB
13Wrong answer0/164ms508 KiB
14Time limit exceeded0/1588ms316 KiB
15Time limit exceeded0/1580ms564 KiB
16Time limit exceeded0/1600ms580 KiB
17Time limit exceeded0/1578ms564 KiB
18Accepted1/19ms564 KiB
19Wrong answer0/141ms564 KiB
20Wrong answer0/129ms564 KiB
21Wrong answer0/157ms564 KiB
22Wrong answer0/124ms780 KiB
23Time limit exceeded0/1600ms564 KiB
24Time limit exceeded0/1587ms564 KiB
25Wrong answer0/27ms500 KiB
26Wrong answer0/210ms432 KiB
27Wrong answer0/228ms444 KiB
28Wrong answer0/128ms584 KiB
29Accepted2/228ms564 KiB
30Wrong answer0/159ms760 KiB
31Accepted1/143ms564 KiB
32Wrong answer0/23ms508 KiB
33Wrong answer0/259ms564 KiB
34Wrong answer0/159ms576 KiB
35Wrong answer0/2123ms704 KiB
36Wrong answer0/259ms564 KiB
37Wrong answer0/259ms564 KiB
38Wrong answer0/259ms564 KiB
39Wrong answer0/13ms316 KiB