結果

問題 No.2334 Distinct Cards
ユーザー Today03
提出日時 2023-10-08 18:47:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 378 bytes
コンパイル時間 1,793 ms
コンパイル使用メモリ 200,192 KB
最終ジャッジ日時 2025-02-17 06:18:27
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> A(n), cnt(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		A[i]--;
		cnt[A[i]]++;
	}
	sort(cnt.rbegin(), cnt.rend());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans++;
		if (k >= cnt[i]) {
			k -= cnt[i];
			cnt[i] = 0;
		} else {
			break;
		}
	}
	cout << ans << endl;
}
0