結果
| 問題 |
No.2334 Distinct Cards
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-04 01:28:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 17 ms / 2,000 ms |
| コード長 | 669 bytes |
| コンパイル時間 | 3,228 ms |
| コンパイル使用メモリ | 249,772 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-29 03:19:53 |
| 合計ジャッジ時間 | 4,346 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 1
#endif
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<int> A(n);
for (int i = 0; i < n; i++) {
int a;
cin >> a;
a--;
A[a]++;
}
priority_queue<int> Q;
for (int i = 0; i < n; i++) {
if (A[i] > 0) {
Q.push(A[i]);
}
}
int ans = 0;
while (1) {
int x = Q.top();
Q.pop();
k -= x;
ans++;
if (k <= 0) {
cout << ans << '\n';
return 0;
}
}
}