結果

問題 No.2334 Distinct Cards
ユーザー SSRS
提出日時 2021-09-30 23:02:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 435 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 171,336 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-28 15:54:12
合計ジャッジ時間 3,029 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i]--;
  } 
  vector<int> cnt(N, 0);
  for (int i = 0; i < N; i++){
    cnt[A[i]]++;
  }
  sort(cnt.begin(), cnt.end(), greater<int>());
  int ans = 0;
  for (int i = 0; i < N; i++){
    K -= cnt[i];
    ans++;
    if (K <= 0){
      break;
    }
  }
  cout << ans << endl;
}
0