-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpaceX.cpp
More file actions
51 lines (47 loc) · 865 Bytes
/
SpaceX.cpp
File metadata and controls
51 lines (47 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// https://basecamp.eolymp.com/az/problems/10030
#include <iostream>
#include <map>
#include <set>
using namespace std;
// struct cmp{
// bool operator()(const int& a, const int& b) const{
// return b < a;
// }
// };
//
// map<int, int, cmp> mp;
map<int, int> mp;
signed main()
{
cin.tie(0)->sync_with_stdio(false);
int n, k;
cin >> n >> k;
for (int i = 1, a; i <= n; ++i)
{
cin >> a;
mp[a]++;
}
int d = (int)mp.size();
if (d <= k)
{
cout << k - d << '\n';
}
else
{
int ans(0);
multiset<int> st;
for (auto to : mp)
{
st.insert(to.second);
}
for (int i : st)
{
ans += i;
--d;
if (d == k)
break;
}
cout << ans << '\n';
}
exit(0);
}