結果

問題 No.2334 Distinct Cards
ユーザー achapi
提出日時 2023-06-02 21:22:41
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 207,752 KB
最終ジャッジ日時 2025-02-13 17:33:55
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	map<int, int> m;
	for (int i = 0; i < N; i++){
		cin >> A[i];
		m[A[i]]++;
	}
	int ans = 0;
	vector<pair<int, int>> p;
	for (auto [x, y] : m){
		p.push_back({y, x});
	}
	sort(p.begin(), p.end());
	while (K > 0){
		ans++;
		K -= p.back().first;
		p.pop_back();
	}
	cout << ans << '\n';
}
0