結果

問題 No.2334 Distinct Cards
ユーザー as277575as277575
提出日時 2023-06-02 21:52:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 118,328 KB
実行使用メモリ 8,540 KB
最終ジャッジ日時 2023-08-28 03:15:56
合計ジャッジ時間 2,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 28 ms
6,128 KB
testcase_13 AC 28 ms
6,248 KB
testcase_14 AC 27 ms
6,188 KB
testcase_15 AC 27 ms
6,152 KB
testcase_16 AC 27 ms
6,168 KB
testcase_17 AC 33 ms
8,392 KB
testcase_18 AC 32 ms
8,440 KB
testcase_19 AC 34 ms
8,540 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 11 ms
4,380 KB
testcase_22 AC 11 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>

using namespace::std;


int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  unordered_map<int, int> c;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    ++c[a];
  }
  vector<int> b;
  for (const auto& [_, cx] : c) b.push_back(cx);
  sort(b.begin(), b.end(), greater<int>());
  int r = 0;
  for (; k > 0; ++r) k -= b[r];
  cout << r << endl; 
  
  

  
  return 0;
}
0