Looking for a Millionaire
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4574 Accepted Submission (s): 1857
Problem description Zhejiang Tongxiang Wu Town A total of n people, please find out the town of the former m monopoly.
Input inputs contain multiple sets of test cases.
Each use case first contains 2 integers n (0<n<=100000) and M (0<m<=10), Where: N is the number of people in town, M is the number of millionaires that need to be found, and the next line is to enter the wealth value of N people in the town.
N and m at 0 indicate the end of the input.
Output please export the wealth of the former m monopoly of Wuzhen, the number of assets in front of the row, if the monopoly less than m, then all output, each group of output accounted for one row.
Sample INPUT3 1 2 5-1 5 3 1 2 3 4 5 0 0
Sample OUTPUT5 5 4 3
SOURCE Zhejiang University Computer Postgraduate exam on the machine-2009
recommendnotonlysuccess | We have carefully selected several similar problems for you:3786 3782 3784 3783 3789
1#include <queue>2#include <cstdio>3#include <iostream>4 using namespacestd;5 intMain ()6 {7 intN, M, I, p;8 9 while(~SCANF ("%d%d", &n, &m), m+N)Ten { One Apriority_queue<int, vector<int, less<int> >Q; - for(i=0; i<n; i++) - { thescanf"%d", &p); - Q.push (p); - } -printf"%d", Q.top ()); + Q.pop (); - intTotal =1; + while(!q.empty ()) A { at if(Total = =m) - Break; -printf"%d", Q.top ()); - Q.pop (); -total++; - } inprintf"\ n"); - to } + return 0; -}
Hangzhou Electric 3785--Looking for monopoly