hash原来做过

<pre name="code" class="cpp">#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int M = 1000001;
#define MIN -99999999
bool hashh[M];
void init()
{
for(int i=0;i<M;i++) hashh[i]=false;
}
int main()
{
int n,m,maxn;
while(scanf("%d%d",&n,&m)!=EOF){

int p;
init();
maxn = MIN;
for(int i=0;i<n;i++)
{
scanf("%d",&p);
p += 500000;
hashh[p]=true;
if(p>maxn) maxn = p;
}
printf("%d",maxn - 500000);
if(--m){

for(int i=maxn - 1; i>= 0; --i){
if(hashh[i]){
printf(" %d",i-500000);
--m;
if(!m) break;
}
}
}
puts("");
}
return 0;
}