結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int N, K;
	std::cin >> N >> K;
	std::vector<std::pair<int,int> > V(N + 1, {0, 0});
	for(int i = 0; i < N; i++) {
		int a;
		std::cin >> a;
		V[a].first++;
		V[a].second = a;
	}
	std::sort(V.rbegin(), V.rend());
	int ans = 0;
	int idx = 0;
	while(K>0&&idx<N){
		K-=V[idx].first;
		idx++;
		if(V[idx].first > 0) ans++;
	}
	std::cout << ans << std::endl;
	return 0;
}
0