結果
問題 | No.2334 Distinct Cards |
ユーザー |
![]() |
提出日時 | 2023-06-02 21:22:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 2,047 ms |
コンパイル使用メモリ | 199,860 KB |
最終ジャッジ日時 | 2025-02-13 17:34:04 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=long long;using ld=long double;ld pie=3.141592653589793;ll inf=2000000000000000000;ll mod=998244353;int main(){ll n,k;cin >> n >> k;vector<ll>a(n);vector<ll>memo(n+1,0);for (ll i = 0; i < n; i++){cin >> a[i];memo[a[i]]+=1;}vector<ll>x;for (ll i = 0; i <= n; i++){if (memo[i]>0){x.push_back(memo[i]);}}sort(x.begin(),x.end());reverse(x.begin(),x.end());ll now=0;for (ll i = 0; i < x.size(); i++){now+=x[i];if (now>=k){cout << i+1 << endl;return 0;}}}