题意:排序
思路:排序
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std; int a[]; bool cmp(int a,int b){
return a>b;//降序
} int main(){
int b[];
int n,m,i,j,k;
while(~scanf("%d%d",&n,&m)){
k=;
for(i=;i<n;++i)
scanf("%d",&b[i]);
for(i=;i<n;++i)
for(j=i+;j<n;++j)
a[k++]=b[i]+b[j];
sort(a,a+k,cmp);
for(i=;i<m-;++i)
printf("%d ",a[i]);
printf("%d\n",a[i]);
}
return ;
}