#include "iostream"
#include "stdio.h"
#include <vector>
#include <cstring>
#include <algorithm>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <ctype.h>
#include <functional>
#include <math.h>
using namespace std;
//1034
int n,m,t;
priority_queue<int> q;
int main(){
//freopen("input.txt","r",stdin);
while(cin>>n>>m){
if(n==0 && m==0) break;
while(!q.empty()) q.pop();
while(n--){
cin>>t;
q.push(t);
}
bool f=true;
while(m--&&!q.empty()){
if(f){
f=false;
cout<<q.top();
}
else
cout<<" "<<q.top();
q.pop();
}
cout<<endl;
}
return 0;
}
/**************************************************************
Problem: 1034
User: cust123
Language: C++
Result: Accepted
Time:40 ms
Memory:1652 kb
****************************************************************/
题目1034:寻找大富翁
最新推荐文章于 2021-02-01 07:58:44 发布