結果

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

ソースコード

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