九度OJ 1035 09浙大真题之优先队列堆排序之《寻找大富翁》
[cpp]#include #include #include using namespace std;priority_queue < int > Q;int main() www.zzzyk.com{int money,m,n;while(~scanf("%d %d",&n,&m)&&n){m=m while(Q.empty()==false)Q.pop();while(n--){scanf("%d",&money);Q.push(money);}if(m){money=Q.top();Q.pop();printf("%d",money);}while(--m){money=Q.top();Q.pop();printf(" %d",money);}printf("\n");}return 0;}
补充:软件开发 , C++ ,