153142025-02-18 10:48:19Leventusz09Maximális szorzat (50 pont)cpp17Wrong answer 3/5064ms1560 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> p, n;
	int zc = 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++;
	}
	sort(n.begin(), n.end(), greater<int>());
	
	while (b != n.size()) {
		M += n[n.size()-1];
		n.pop_back();
		zc++;
	}
	int s, i;
	if (M < 0) {
		cout << -1 << endl;
		return 0;
	}
	if (M == 0) goto end;
	if (zc > M) goto end;
	M -= zc;
	while (zc--) p.push_back(1);
	
	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 0;
	}
	int o = 1;
	for (int& i : p) o = (unsigned long long)o * i MOD;
	for (int& i : n) o = (unsigned long long)o * i MOD;
	cout << o << endl;
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base3/50
1Accepted0/01ms316 KiB
2Wrong answer0/01ms316 KiB
3Accepted0/01ms508 KiB
4Wrong answer0/01ms316 KiB
5Wrong answer0/04ms564 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms532 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/26ms436 KiB
11Wrong answer0/254ms1548 KiB
12Wrong answer0/157ms1508 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/14ms564 KiB
15Wrong answer0/123ms932 KiB
16Wrong answer0/123ms980 KiB
17Wrong answer0/123ms940 KiB
18Accepted1/19ms316 KiB
19Runtime error0/143ms1452 KiB
20Runtime error0/132ms1516 KiB
21Runtime error0/159ms1532 KiB
22Runtime error0/126ms1452 KiB
23Wrong answer0/159ms1168 KiB
24Wrong answer0/157ms1496 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/26ms408 KiB
27Runtime error0/229ms948 KiB
28Runtime error0/129ms1008 KiB
29Runtime error0/223ms944 KiB
30Wrong answer0/161ms1556 KiB
31Wrong answer0/145ms1452 KiB
32Wrong answer0/22ms316 KiB
33Wrong answer0/261ms1508 KiB
34Wrong answer0/161ms1456 KiB
35Wrong answer0/264ms1488 KiB
36Wrong answer0/261ms1560 KiB
37Wrong answer0/261ms1356 KiB
38Wrong answer0/261ms1448 KiB
39Wrong answer0/11ms316 KiB