結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 RE -
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 RE -
testcase_11 AC 2 ms
6,676 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 66 ms
6,676 KB
testcase_15 AC 61 ms
6,676 KB
testcase_16 RE -
testcase_17 AC 70 ms
8,704 KB
testcase_18 AC 74 ms
8,704 KB
testcase_19 AC 75 ms
8,704 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 32 ms
6,676 KB
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 = (int)b.size() - 1;
	int ans = 0;
	while(k){
		k -= b[s];
		s--;
		ans++;
	}
	cout << ans << endl;
}
0