153132025-02-18 10:25:19Leventusz09Maximális szorzat (50 pont)cpp17Wrong answer 14/5063ms1560 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
#define MOD % 1'000'000'007
using namespace std;

signed main() {
	int N, M, b;
	cin >> N >> M >> b;
	//vector<int> A(N);
	vector<int> p, n;
	int zc = 0;
	//int mini = 0, maxi = 0;
	//int sn = 0;
	for (int i = 0, a; i < N; i++) {
		cin >> a;
		if (a < 0) n.push_back(a);
		else if (a > 0) p.push_back(a);
		else zc++;

		//if (A[maxi] > a) maxi = i;
		//if (A[mini] < a) mini = i;
		//if (a < 0) sn+=-a;
	}
	sort(n.begin(), n.end());
	
	while (b != n.size()) {
		M += n[n.size()-1];
		n.pop_back();
		//p.push_back(0);
		zc++;
	}
	int s, i;
	if (M < 0) {
		cout << -1 << endl;
		return 2;
	}
	if (M == 0) goto end;
	if (zc > M) goto end;
	M -= zc;
	while (zc--) p.push_back(1);
	//cout << "zc=" << zc << "; M=" << M << "\n";
	
	sort(p.begin(), p.end());
	while (M) {
		int i = 1;
		p[0]++;
		M--;
		while (M && i<p.size() && p[i] <= p[i - 1]) {
			p[i]++;
			M--;
			i++;
		}
	}

	end:
	if (zc > 0) {
		cout << 0 << endl;
		return 1;
	}
	//for (int& i : p) cout << i << "; ";
	//cout << "\n";
	int o = 1;
	for (int& i : p) o = o * i MOD;
	for (int& i : n) o = o * i MOD;
	cout << o << endl;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/04ms564 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms500 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/26ms760 KiB
11Wrong answer0/256ms1452 KiB
12Wrong answer0/159ms1452 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/14ms564 KiB
15Runtime error0/119ms908 KiB
16Wrong answer0/124ms1024 KiB
17Runtime error0/121ms1004 KiB
18Runtime error0/19ms316 KiB
19Runtime error0/143ms1560 KiB
20Runtime error0/132ms1320 KiB
21Runtime error0/161ms1404 KiB
22Runtime error0/125ms1348 KiB
23Wrong answer0/161ms1324 KiB
24Wrong answer0/159ms1452 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/26ms564 KiB
27Runtime error0/230ms1024 KiB
28Runtime error0/130ms944 KiB
29Runtime error0/224ms956 KiB
30Accepted1/163ms1328 KiB
31Runtime error0/135ms1452 KiB
32Accepted2/22ms316 KiB
33Accepted2/263ms1460 KiB
34Wrong answer0/161ms1504 KiB
35Wrong answer0/263ms1452 KiB
36Accepted2/261ms1524 KiB
37Accepted2/261ms1448 KiB
38Accepted2/261ms1452 KiB
39Accepted1/11ms388 KiB