mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 14:36:27 +00:00
838. 堆排序
https://www.acwing.com/problem/content/submission/code_detail/7418242/
This commit is contained in:
parent
2b1cbc61af
commit
4b6fd25256
21
AcWing/838/838.cpp
Normal file
21
AcWing/838/838.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int n, m, t;
|
||||||
|
map<int, int> a;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cin >> n >> m;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
cin >> t;
|
||||||
|
a[t]++;
|
||||||
|
}
|
||||||
|
for (auto it = a.begin(); it != a.end(); it++) {
|
||||||
|
for (int i = 0; i < it->second && m; i++, m--) {
|
||||||
|
cout << it->first << ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user