diff --git a/AcWing/838/838.cpp b/AcWing/838/838.cpp new file mode 100644 index 00000000..e2b24807 --- /dev/null +++ b/AcWing/838/838.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int n, m, t; +map 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; +}