結果
問題 | No.2334 Distinct Cards |
ユーザー |
![]() |
提出日時 | 2023-06-02 21:52:39 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 497 bytes |
コンパイル時間 | 4,183 ms |
コンパイル使用メモリ | 251,784 KB |
最終ジャッジ日時 | 2025-02-13 18:05:20 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>using namespace std;using namespace atcoder;typedef modint998244353 mint;typedef long long ll;int main(){int n, k; cin >> n >> k;vector<int> bucket(n+1);for (int i=0; i<n; i++){int a; cin >> a;bucket[a]++;}sort(bucket.begin(), bucket.end());reverse(bucket.begin(), bucket.end());int piv = 0;int ans = 1;for (int i=0; i<k; i++){if (bucket[piv] == 0){piv++;ans++;}bucket[piv]--;}cout << ans << endl;}