結果

問題 No.2334 Distinct Cards
ユーザー YoungmanofxingyeYoungmanofxingye
提出日時 2023-06-14 00:04:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 3,143 ms
コンパイル使用メモリ 175,612 KB
実行使用メモリ 10,364 KB
最終ジャッジ日時 2023-09-04 12:26:47
合計ジャッジ時間 4,438 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 51 ms
7,668 KB
testcase_13 AC 49 ms
7,676 KB
testcase_14 AC 48 ms
7,608 KB
testcase_15 AC 48 ms
7,564 KB
testcase_16 AC 48 ms
7,640 KB
testcase_17 AC 64 ms
10,360 KB
testcase_18 AC 63 ms
10,360 KB
testcase_19 AC 70 ms
10,364 KB
testcase_20 AC 11 ms
4,380 KB
testcase_21 AC 12 ms
4,380 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int t;
void solve()
{
	int n,k;
	scanf("%lld%lld",&n,&k);
	map<int,int> mp;
	for (int i = 0; i < n; i ++)
	{
		int x;
		scanf("%lld",&x);
		mp[x] ++;
	}
	vector<int> v;
	for (auto c:mp)
	{
		v.push_back(c.second);
	}
	sort(v.begin(),v.end(),greater<int>());
	int now = 0;
	for (int i = 0; i < (int)v.size(); i ++)
	{
		now += v[i];
		if(now >= k)
		{
			printf("%lld\n",i + 1);
			break;
		}
	}
}
signed main()
{
	t = 1;
	while(t --)
	{
		solve();
	}
	return 0;
}
0