結果

問題 No.2334 Distinct Cards
ユーザー yansi819yansi819
提出日時 2024-03-18 20:19:22
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 4,278 ms
コンパイル使用メモリ 271,168 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-09-30 05:01:38
合計ジャッジ時間 6,704 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
  int N, K; cin >> N >> K;
  map<int, int> mp;
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    mp[a]++;
  }
  vector<int> vec;
  for (auto p: mp) {
    vec.push_back(p.second);
  }
  sort(vec.rbegin(), vec.rend());
  int ans = 0, sum = 0, i = 0;
  while (sum < K) {
    sum += vec[i];
    ans++;
    i++;
  }
  cout << ans << endl;
  return 0;
}
0