149792025-02-10 16:20:18antiMaximális szorzat (50 pont)cpp17Wrong answer 0/501ms508 KiB
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

int main()
{
    ifstream fin("be5.txt");
    int n, k, b;
    fin >> n >> k >> b;
    int t[n];
    for(int i=0; i<n; i++){
        fin >> t[i];
    }
    sort(t, t+n);
    //cout << t[1495] << " " << t[1507];

    if(b%2 == 0){
        int i=b, neg = 0;
        long long 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(meg > 1000000007){
                while(meg>1000000007){
                    meg -= 1000000007;
                }
            }
        }
        if(neg!=b){
            //cout << -1;
        }else{
            cout << meg;
        }
        /*for(int i=0; i<n; i++){
            cout << t[i] << endl;
        */
    }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
base0/50
1Wrong answer0/01ms508 KiB
2Wrong answer0/01ms316 KiB
3Wrong answer0/01ms316 KiB
4Wrong answer0/01ms508 KiB
5Wrong answer0/01ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/11ms316 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/11ms316 KiB
15Wrong answer0/11ms508 KiB
16Wrong answer0/11ms316 KiB
17Wrong answer0/11ms316 KiB
18Wrong answer0/11ms316 KiB
19Wrong answer0/11ms316 KiB
20Wrong answer0/11ms508 KiB
21Wrong answer0/11ms316 KiB
22Wrong answer0/11ms316 KiB
23Wrong answer0/11ms316 KiB
24Wrong answer0/11ms316 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/21ms316 KiB
27Wrong answer0/21ms316 KiB
28Wrong answer0/11ms320 KiB
29Wrong answer0/21ms316 KiB
30Wrong answer0/11ms316 KiB
31Wrong answer0/11ms508 KiB
32Wrong answer0/21ms372 KiB
33Wrong answer0/21ms316 KiB
34Wrong answer0/11ms316 KiB
35Wrong answer0/21ms316 KiB
36Wrong answer0/21ms316 KiB
37Wrong answer0/21ms316 KiB
38Wrong answer0/21ms316 KiB
39Wrong answer0/11ms508 KiB