結果
| 問題 |
No.2334 Distinct Cards
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-05 14:50:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 113 ms / 2,000 ms |
| コード長 | 755 bytes |
| コンパイル時間 | 1,303 ms |
| コンパイル使用メモリ | 115,068 KB |
| 最終ジャッジ日時 | 2025-02-15 06:14:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
int main(){
int N,K;
cin>>N>>K;
vector<int> A(N);
for(int i=0;i<N;i++)cin>>A[i];
map<int,int> mp;
for(int i=0;i<N;i++){
mp[A[i]]++;
}
priority_queue<P> pq;
for(auto [v,num]:mp){
pq.emplace(num,v);
}
set<int> ans;
int cnt=0;
while(cnt<K && !pq.empty()){
auto [num,v]=pq.top();
cnt+=num;
pq.pop();
ans.insert(v);
}
cout<<ans.size()<<endl;
}