結果
問題 | No.2334 Distinct Cards |
ユーザー |
|
提出日時 | 2023-06-02 21:34:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 5,598 ms |
コンパイル使用メモリ | 236,488 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-12-28 16:41:47 |
合計ジャッジ時間 | 5,454 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define rep1(i, n) for (int i = 1; i < (int)(n + 1); i++)using ll = long long;using P = pair<int, int>;using Graph = vector<vector<int>>;using mint = modint998244353;int main(){ios_base::sync_with_stdio(0);cin.tie(0);int n, k;cin >> n >> k;map<int, int> m;rep(i, n){int a; cin >> a;if(m.count(a)){m[a]++;}else{m[a] = 1;}}vector<int> d;for(auto itr = m.begin(); itr != m.end(); itr++){d.push_back(itr->second);}sort(d.begin(), d.end());reverse(d.begin(), d.end());int ans = 0;while(k>0){k -= d[ans];ans++;}cout << ans << endl;}