```cpp
#include <bits/stdc++.h>
#define LL long long
#define inf 2147483647
#define N 300001
#define strnull 4294967295
using namespace std;
inline LL read(){
LL f=1,x=0;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return f*x;
}
int n,k,a[N],cnt,pre,now;
priority_queue<int>q;
int main(){
n=read(),k=read();
for(int i=1;i<=n;i++)a[i]=read(),q.push(-a[i]);
while(!q.empty()&&cnt<k){
now=q.top();q.pop();
if(now==pre)continue;
cnt++,pre=now;
for(int i=1;i<=n;i++){
int x=now*a[i];
if(x>=-inf&&x<=0)q.push(x);
}
}
printf("%d",-now);
return 0;
}
```
改了之后没有什么区别,Wa了5个
by Trinity @ 2018-10-31 08:58:50
开 long long
by _zhx @ 2023-06-16 17:12:16
@[Trinity](/user/60089)
by _zhx @ 2023-06-16 17:12:41