結果
| 問題 |
No.2334 Distinct Cards
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-02 21:51:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 555 bytes |
| コンパイル時間 | 1,933 ms |
| コンパイル使用メモリ | 171,604 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-28 17:22:14 |
| 合計ジャッジ時間 | 2,996 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)
int a[100010];
int main(void){
cin.tie(nullptr); ios_base::sync_with_stdio(false);
int i,j,k;
int N,K;
cin >> N >> K;
for(i=1;i<=N;i++){
int c;
cin >> c;
a[c]++;
}
vector<int> v;
for(i=1;i<=N;i++) if(a[i]!=0) v.push_back(a[i]);
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
int ans=0,s=0;
REP(i,v.size()){
ans++;
s+=v[i];
if(s>=K) break;
}
cout << ans << endl;
return 0;
}