1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 long int a[1000005]; 5 long int N; 6 bool cmp(int a,int b) 7 { 8 return a>b; 9 } 10 int main() 11 { 12 int M; 13 cin >> N >> M; 14 if(N<M)M=N; 15 for ( int i = 0; i < N; i++) 16 { 17 cin >> a[i]; 18 } 19 sort(a,a+N,cmp); 20 for ( int i = 0; i < M; i++) 21 { 22 printf("%ld",a[i]); 23 if (i != M - 1)printf(" "); 24 } 25 return 0; 26 }