結果
| 問題 |
No.2334 Distinct Cards
|
| コンテスト | |
| ユーザー |
yukster714
|
| 提出日時 | 2023-06-11 12:26:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 120 ms / 2,000 ms |
| コード長 | 581 bytes |
| コンパイル時間 | 958 ms |
| コンパイル使用メモリ | 78,096 KB |
| 実行使用メモリ | 12,928 KB |
| 最終ジャッジ日時 | 2025-01-03 03:50:01 |
| 合計ジャッジ時間 | 3,337 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
int main()
{
int n, k; cin>>n>>k;
vector<int>a(n);
map<int,int>b; // kind -> count
multimap<int,int>c; // count -> kind
rep(i,n) cin>>a[i];
rep(i,n) b[a[i]]++;
for(auto it=b.begin();it!=b.end();it++){
c.emplace(it->second,it->first);
}
int ans=0;
int cnt=0;
for(auto it=c.rbegin();it!=c.rend();it++){
ans++;
cnt+=it->first;
if(cnt>=k) break;
}
cout << ans << endl;
return 0;
}
yukster714