結果
問題 | No.2334 Distinct Cards |
ユーザー |
|
提出日時 | 2023-06-02 21:21:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 69 ms / 2,000 ms |
コード長 | 385 bytes |
コンパイル時間 | 946 ms |
コンパイル使用メモリ | 86,592 KB |
実行使用メモリ | 8,704 KB |
最終ジャッジ日時 | 2024-12-28 16:01:54 |
合計ジャッジ時間 | 2,348 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include<iostream>#include<map>#include<vector>#include<algorithm>#include<cassert>using namespace std;int main(){int N,K;cin>>N>>K;map<int,int>cnt;for(;N--;){int A;cin>>A;cnt[A]++;}vector<int>V;for(pair<int,int>p:cnt)V.push_back(p.second);sort(V.begin(),V.end());int ans=0;for(int i=V.size();K>0&&i--;){K-=V[i];ans++;}cout<<ans<<endl;}