153172025-02-18 11:09:55Leventusz09Maximális szorzat (50 pont)cpp17Wrong answer 18/5061ms1560 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);
	zc = 0;
	
	if (p.size() == 0) return 1 / p.size(); //hiba
	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
base18/50
1Accepted0/01ms316 KiB
2Accepted0/01ms500 KiB
3Accepted0/01ms316 KiB
4Accepted0/01ms316 KiB
5Wrong answer0/04ms604 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/24ms388 KiB
11Wrong answer0/254ms1512 KiB
12Wrong answer0/157ms1452 KiB
13Wrong answer0/11ms316 KiB
14Wrong answer0/14ms564 KiB
15Accepted1/118ms884 KiB
16Wrong answer0/123ms1036 KiB
17Accepted1/121ms972 KiB
18Accepted1/18ms404 KiB
19Wrong answer0/141ms1452 KiB
20Wrong answer0/130ms1488 KiB
21Wrong answer0/159ms1424 KiB
22Wrong answer0/125ms1560 KiB
23Wrong answer0/159ms1172 KiB
24Wrong answer0/157ms1456 KiB
25Wrong answer0/21ms316 KiB
26Wrong answer0/24ms452 KiB
27Wrong answer0/229ms944 KiB
28Wrong answer0/129ms924 KiB
29Runtime error0/223ms1020 KiB
30Accepted1/161ms1532 KiB
31Accepted1/134ms1464 KiB
32Accepted2/21ms412 KiB
33Accepted2/259ms1336 KiB
34Wrong answer0/159ms1444 KiB
35Wrong answer0/261ms1420 KiB
36Accepted2/259ms1452 KiB
37Accepted2/259ms1448 KiB
38Accepted2/259ms1456 KiB
39Accepted1/11ms316 KiB