Submission #3184381
Source Code Expand
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}
int n, k, ans;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> k;
map<int, int> mem;
vector<Pii> cnt;
rep(i, 0, n) {
int p; cin >> p;
mem[p]++;
}
for (auto itr = mem.begin(); itr != mem.end(); ++itr) {
cnt.pb(mp(itr->second, itr->first));
}
sort(all(cnt));
int i = 0;
while(cnt.size() - i > k) {
ans += cnt[i].first;
++i;
}
cout << ans << endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
C - Not so Diverse |
User |
kage |
Language |
C++14 (GCC 5.4.1) |
Score |
300 |
Code Size |
1241 Byte |
Status |
AC |
Exec Time |
108 ms |
Memory |
11764 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
300 / 300 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt, sample3.txt |
All |
sample1.txt, sample2.txt, sample3.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 2.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name |
Status |
Exec Time |
Memory |
1.txt |
AC |
1 ms |
256 KB |
10.txt |
AC |
23 ms |
256 KB |
11.txt |
AC |
27 ms |
256 KB |
12.txt |
AC |
108 ms |
11764 KB |
13.txt |
AC |
33 ms |
512 KB |
2.txt |
AC |
1 ms |
256 KB |
3.txt |
AC |
25 ms |
256 KB |
4.txt |
AC |
33 ms |
384 KB |
5.txt |
AC |
39 ms |
384 KB |
6.txt |
AC |
32 ms |
512 KB |
7.txt |
AC |
16 ms |
256 KB |
8.txt |
AC |
17 ms |
256 KB |
9.txt |
AC |
49 ms |
1280 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |