97992024-03-07 00:07:13SleepyOverlordMaximális szorzat (50 pont)cpp17Time limit exceeded 38/50600ms7000 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define MX(x, y) x = max(x, y);
#define MN(x, y) x = min(x, y);

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

template <class T> ostream& operator <<(ostream & os, const vector<T> &vec)
{
	for (int i = 0; i < vec.size() - 1; ++i) os << vec[i] << ' ';
	return os << vec[vec.size() - 1];
}

template <class T1, class T2> ostream& operator <<(ostream & os, const pair<T1, T2> &p)
{
	return os << p.X << " " << p.Y;
}

template <typename T>
void pr(T var1)
{
	cout << var1 << '\n';
}
template <typename T, typename... Types>
void pr(T var1, Types... var2)
{
	cout << var1;
	pr(var2...);
}

void in(int &n, VI &a) //array of ints
{
	cin >> n;
	a.CL, a.RS(n + 1);
	FOR(i, 1, n) cin >> a[i];
}

void in(int &n, VS &a) //array of strings
{
	cin >> n;
	a.CL, a.RS(n + 1);
	FOR(i, 1, n) cin >> a[i];
}

void in(int &n, VPII &a) //array of pairs
{
	cin >> n;
	a.CL, a.RS(n + 1);
	FOR(i, 1, n) cin >> a[i].X >> a[i].Y;
}

void in(int &n, int &m, VVI &g) //unweighted graph
{
	cin >> n >> m;
	g.CL, g.RS(n + 1);
	FOR(i, 1, n)
	{
		int x, y;
		cin >> x >> y;
		g[x].PB(y);
		g[y].PB(x);
	}
}

void in(int &n, VVI &g) //unweighted tree
{
	cin >> n;
	g.CL, g.RS(n + 1);
	FOR(i, 1, n - 1)
	{
		int x, y;
		cin >> x >> y;
		g[x].PB(y);
		g[y].PB(x);
	}
}

void in(int &n, int &m, vector <VPII> &g) //weighted graph
{
	cin >> n >> m;
	g.CL, g.RS(n + 1);
	FOR(i, 1, n)
	{
		int x, y, z;
		cin >> x >> y >> z;
		g[x].PB({y, z});
		g[y].PB({x, z});
	}
}

void in(int &n, vector <VPII> &g) //weighted tree
{
	cin >> n;
	g.CL, g.RS(n + 1);
	FOR(i, 1, n - 1)
	{
		int x, y, z;
		cin >> x >> y >> z;
		g[x].PB({y, z});
		g[y].PB({x, z});
	}
}

const int MOD = 1e9 + 7;

int n, m, k;
VI a;
priority_queue<int> neg, poz;

int main()
{
	#ifdef AT_HOME
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

	cin >> n >> m >> k;
	a.RS(n + 1);
	FOR(i, 1, n)
	{
		cin >> a[i];
		if (a[i] < 0) neg.push(a[i]);
		else poz.push(-a[i]);
	}
	while (neg.SZ > k)
	{
		int mn = neg.top();
		m -= -mn;
		neg.pop();
		poz.push(0);
	}
	while (m)
	{
		--m;
		int mn = poz.top();
		poz.pop();
		poz.push(mn - 1);
	}
	int sol = 1;
	while (!neg.empty())
	{
		sol = (LL)sol * neg.top() % MOD;
		neg.pop();
	}
	while (!poz.empty())
	{
		sol = (LL)sol * (-poz.top()) % MOD;
		poz.pop();
	}
	pr(sol);

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base38/50
1Accepted0/03ms1892 KiB
2Accepted0/03ms2116 KiB
3Accepted0/03ms2332 KiB
4Accepted0/03ms2516 KiB
5Accepted0/04ms2852 KiB
6Accepted2/23ms2792 KiB
7Accepted2/23ms3000 KiB
8Accepted2/23ms3112 KiB
9Accepted2/23ms3332 KiB
10Accepted2/26ms3672 KiB
11Accepted2/243ms5304 KiB
12Accepted1/146ms5564 KiB
13Accepted1/13ms3780 KiB
14Accepted1/17ms4244 KiB
15Time limit exceeded0/1600ms3956 KiB
16Accepted1/132ms5508 KiB
17Time limit exceeded0/1575ms4024 KiB
18Accepted1/18ms5540 KiB
19Runtime error0/116ms6408 KiB
20Runtime error0/114ms6392 KiB
21Runtime error0/120ms6724 KiB
22Runtime error0/113ms6684 KiB
23Accepted1/146ms6612 KiB
24Accepted1/146ms7000 KiB
25Accepted2/23ms4884 KiB
26Accepted2/24ms5160 KiB
27Runtime error0/212ms6012 KiB
28Runtime error0/112ms6116 KiB
29Wrong answer0/229ms6044 KiB
30Accepted1/135ms6788 KiB
31Time limit exceeded0/1572ms5224 KiB
32Accepted2/24ms4896 KiB
33Accepted2/235ms6788 KiB
34Accepted1/137ms6788 KiB
35Accepted2/239ms6788 KiB
36Accepted2/235ms6788 KiB
37Accepted2/235ms6784 KiB
38Accepted2/235ms6788 KiB
39Accepted1/14ms4888 KiB