結果
| 問題 | No.2334 Distinct Cards |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-05 14:50:28 |
| 言語 | C++17 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 70 ms / 2,000 ms |
| + 645µs | |
| コード長 | 755 bytes |
| 記録 | |
| コンパイル時間 | 829 ms |
| コンパイル使用メモリ | 130,456 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2026-10-15 07:51:49 |
| 合計ジャッジ時間 | 3,213 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
#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;
}