Submission #2212229


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n, k, ans = 0;
    map<int, int> ball;
    vector<int> count;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (!ball[a]) ball[a] = 1;
        else ball[a]++;
    }
    for (auto it = ball.begin(); it != ball.end(); it++)
        count.push_back(it->second);
    sort(count.begin(), count.end());
    if (ball.size() <= k) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < ball.size() - k; i++)
        ans += count[i];
    cout << ans << endl;
}

Submission Info

Submission Time
Task C - Not so Diverse
User zohe
Language C++14 (GCC 5.4.1)
Score 300
Code Size 619 Byte
Status AC
Exec Time 166 ms
Memory 10748 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 19
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 65 ms 256 KB
11.txt AC 71 ms 256 KB
12.txt AC 166 ms 10748 KB
13.txt AC 82 ms 512 KB
2.txt AC 1 ms 256 KB
3.txt AC 67 ms 256 KB
4.txt AC 85 ms 384 KB
5.txt AC 84 ms 384 KB
6.txt AC 80 ms 384 KB
7.txt AC 57 ms 256 KB
8.txt AC 58 ms 256 KB
9.txt AC 104 ms 1152 KB
sample1.txt AC 1 ms 256 KB
sample2.txt AC 1 ms 256 KB
sample3.txt AC 1 ms 256 KB