結果

問題 No.2334 Distinct Cards
ユーザー YwestbuilderkYwestbuilderk
提出日時 2024-01-23 16:57:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 353 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 212,872 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-01-23 16:57:18
合計ジャッジ時間 5,553 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
6,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 79 ms
8,704 KB
testcase_18 AC 74 ms
8,704 KB
testcase_19 AC 86 ms
8,704 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	int n,k;
	cin >> n >> k;
	map<int,int> m;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		m[a]++;
	}
	vector<int> b;
	for(auto [key,value] : m){
		b.push_back(value);
	}
	sort(b.begin(),b.end());
	int s = n - 1;
	int ans = 0;
	while(k){
		k -= b[s];
		s--;
		ans++;
	}
	cout << ans << endl;
}
0