Hangzhou Electric 3785--Looking for monopoly

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.