結果
問題 | No.2334 Distinct Cards |
ユーザー |
|
提出日時 | 2023-06-02 21:56:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 2,619 ms |
コンパイル使用メモリ | 207,900 KB |
最終ジャッジ日時 | 2025-02-13 18:10:17 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h>using namespace std;int main() {int N, K;cin >> N >> K;int cnt = 0;map<int, int>m;for (int i = 0; i < N; i++) {int A;cin >> A;m[A]++;}vector<pair<int, int>>A;for (auto w : m) {A.emplace_back(w.second, w.first);}sort(A.begin(), A.end(), greater<pair<int, int>>());int M = A.size();int ans = 0;for (int i = 0; i < M + 1; i++) {if (K > 0) {ans++;K -= A[i].first;}else {cout << ans << endl;break;}}}