結果

問題 No.2334 Distinct Cards
ユーザー Ray otaku
提出日時 2023-06-07 14:53:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 463 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 172,408 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-29 19:48:54
合計ジャッジ時間 3,190 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 17 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 

using namespace std;


int main() {
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n + 1);
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        cnt[x]++;
    }        
    sort(cnt.begin(), cnt.end(), greater<int>());
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        if (k >= cnt[i]) ans++, k -= cnt[i];
        else if (k) ans++, k = 0;
        else break;
    }
    cout << ans;
    return 0;
}
0