求助
查看原帖
求助
550775
rsy_楼主2023/2/16 13:53

为啥MLE了/kk

MLE了一个点:

#include <iostream>
#include <algorithm>
#include <queue>
#include <set>

using namespace std;
const int N = 110, M = 2e8 + 10;

priority_queue<long long> q;
int cnt, n, m;
long long ans[M], a[N];

int main(){
	scanf("%d%d",&n,&m);              
	for(int i =1;i<=n;i++) scanf("%lld",&a[i]), a[i]=0-a[i]; 
	q.push(-1);
	while(cnt < m+1){
		long long x = q.top(); x = -x;
//		cout << x << "\n";
		q.pop();
		if(x>ans[cnt]){
//			cout << x << "\n";
			ans[++cnt] = x;
			for(int i = 1; i <= n; i ++) q.push(x*a[i]);
		}
	} 
	cout << ans[cnt];
	return 0;
}
2023/2/16 13:53
加载中...