結果

問題 No.2334 Distinct Cards
ユーザー Hartik Salaria
提出日時 2023-06-05 22:51:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,701 ms
コンパイル使用メモリ 198,868 KB
最終ジャッジ日時 2025-02-13 23:00:58
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n + 1);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    sort(cnt.rbegin(), cnt.rend());
    int ans = 0;
    for (int i = 0; i < n && k > 0; ++i) {
        ans++;
        k -= cnt[i];
    }
    cout << ans << '\n';
    return 0;
}
0