http://acm.hdu.edu.cn/showproblem.php?pid=1280
#include <stdio.h>
#include <string.h>
#define N 10001
int n,m;
int a[N],cc[N];
int main()
{
while(scanf("%d%d",&n,&m) != EOF)
{
memset(cc,0,sizeof(cc));
int i,j;
int max = 0;
for(i = 0; i < n; ++i)
{
scanf("%d",&a[i]);
if(max < a[i])
max = a[i];
for(j = 0; j < i; ++j)
cc[a[i] + a[j]]++;
}
for(j = 0,i = (max<<1); m;--i)
while(cc[i]-- && m)
{
--m;
a[j++] = i;
}
for(i = 0; i < j-1; ++i)///额。。。PE了一次。。。
printf("%d ",a[i]);
printf("%d\n",a[i]);
}
return 0;
}