Ocrosoft Contest1316-The road to the programming of ~~~~~ the third issue I: Looking for a Millionaire

Source: Internet
Author: User

Http://acm.ocrosoft.com/problem.php?cid=1316&pid=8

Title Description

A town in Hangzhou, Zhejiang has a total of n individuals, please find the town's former m monopoly.

Input

The input contains 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 output Wuzhen former M monopoly property number, property of the row front, if the monopoly less than m, then all output, each group of output accounted for a row.

Sample input
3 11 6 25 32 3 4 5 60 0
Sample output
66 5 4

Code:

#include <bits/stdc++.h>using namespace Std;const int maxn = 1e5 + 10;int N, m;double num[maxn];bool cmp (int x, int Y) {    return x > y;} int main () {    while (~scanf ("%d%d", &n, &m)) {        if (! N &&! M) break;        for (int i = 1; I <= N; i + +)            scanf ("%lf", &num[i]);        Sort (num + 1, num + 1 + N, CMP);        for (int i = 1; I <= M; i + +) {            cout << num[i];            printf ("%s", I! = M?) "": "\ n");}    }    return 0;}

  

Ocrosoft Contest1316-The road to the programming of ~~~~~ the third issue I: Looking for a Millionaire

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.