Report Research Institute survey showed that by the end of 2017, China more than 100 million yuan of personal assets of high net worth population of 15 million people. N hypothesis given individual's personal assets value, Monopoly quickly identify assets ranked first M bits.
Input formats:
First, given two input positive integers N ( ≤ . 1 0 . 6 ), and M ( ≤ . 1 0), where N is the total number, M is the number required to identify the Monopoly; given next line N individual personal asset value, $ million units, not to exceed the scope of a long integer integer. Between numbers separated by a space.
Output formats:
Assets in the front row output by the row non-increasing order of individual asset values of the M-bit Monopoly. Between numbers separated by spaces, not end with extra spaces.
Sample input:
8 3
8 12 7 3 20 9 5 18
Sample output:
20 18 12
Use C ++ library functions have been defined, for this question a little more useful.
Priority Queue
priority_queue <int, vector <int> , greater <int >> s; // represents a greater insertion elements in ascending (small to large) order
Several of the more important functions
Basic operation:
empty () if the queue is empty, returns true
pop () to delete the top element, delete the first element
push () to one element
size () Returns the number of elements in the priority queue has
top () Returns the top element of the priority queue, returns the priority queue has the highest priority element
In the default priority queue, high priority, first-out team. In the default int type in, first-out team to a larger number.
code show as below: