結果

問題 No.2334 Distinct Cards
ユーザー 河城白露河城白露
提出日時 2023-06-02 21:23:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 640 bytes
コンパイル時間 651 ms
コンパイル使用メモリ 83,132 KB
実行使用メモリ 4,464 KB
最終ジャッジ日時 2023-08-28 02:38:21
合計ジャッジ時間 1,819 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,464 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 15 ms
4,380 KB
testcase_13 AC 15 ms
4,376 KB
testcase_14 AC 15 ms
4,380 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 15 ms
4,380 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 14 ms
4,380 KB
testcase_19 AC 14 ms
4,376 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 13 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define ll long long
#define db double
using namespace std;
const ll N = 1e5 + 100;
ll tt,cnt[N],n,k;
void solve() {
	memset(cnt,0,sizeof(cnt));
	scanf("%lld%lld",&n,&k);
	for (ll i = 1;i <= n;i++) {
		ll x;
		scanf("%lld",&x);
		cnt[x]++;
	}
	sort(cnt + 1,cnt + n + 1);
	ll ans = 0;
	for(ll i = n;i >= 1;i--) {
		k -= cnt[i];
		ans++;
		if (k <= 0) {
			break;
		}
	}
	printf("%lld",ans);
}
int main() {
	tt = 1;
	while(tt) {
		solve();
		tt--;
	}
	return 0;
}
0