結果

問題 No.2334 Distinct Cards
ユーザー 👑 CleyL
提出日時 2023-06-13 13:35:38
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 433 bytes
コンパイル時間 1,079 ms
コンパイル使用メモリ 89,092 KB
最終ジャッジ日時 2025-02-14 02:15:03
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int n,k;cin>>n>>k;
	map<int,int> A;
	for(int i = 0; n > i; i++){
		int x;cin>>x;
		A[x]++;
	}
	vector<int> B(A.size());
	for(auto x: A){
		B.push_back(x.second);
	}
	sort(B.begin(), B.end(), greater<int>());
	int nw = 0;
	for(int i = 0; n > i; i++){
		nw += B[i];
		if(nw >= k){
			cout << i+1 << endl;
			return 0;
		}
	}
}
0