尋找大富翁 HDU 3785

2021-09-12 11:51:40 字數 511 閱讀 9415

浙江桐鄉烏鎮共有n個人,請找出該鎮上的前m個大富翁.

input

輸入包含多組測試用例.

每個用例首先包含2個整數n(0output

請輸出烏鎮前m個大富翁的財產數,財產多的排前面,如果大富翁不足m個,則全部輸出,每組輸出佔一行.

sample input

3 12 5 -1

5 31 2 3 4 5

0 0sample output

55 4 3

【**】

#include

#include

#include

using namespace std;

bool cmp

(int a,

int b)

intmain()

}else

}printf

("\n");

}return0;

}

【解析】

這道題要用到sort函式,不然會超時。

HDU3785 尋找大富翁

stl最大堆演算法 include include include include includeint n,m std vectormen int in int main std sort men.begin men.end std greater else std make heap men.b...

HDU 3785 尋找大富翁

problem description 浙江桐鄉烏鎮共有n個人,請找出該鎮上的前m個大富翁.input 輸入包含多組測試用例.每個用例首先包含2個整數n 0output 請輸出烏鎮前m個大富翁的財產數,財產多的排前面,如果大富翁不足m個,則全部輸出,每組輸出佔一行.sample input 3 1 ...

尋找大富翁

015年胡潤研究院的調查顯示,截至2014年9月,個人資產在600萬元以上高淨值人群達290萬人。假設給出n個人的個人資產值,請快速找出資產排前m位的大富翁。輸入首先給出兩個正整數n 10 6 和 m 1 0 其中 n為總人數,m為需要找出的大富翁數 接下來一行給出 n個人的個人資產值,以百萬元為單...