結果
問題 |
No.2334 Distinct Cards
|
ユーザー |
|
提出日時 | 2023-06-02 21:28:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 433 bytes |
コンパイル時間 | 2,082 ms |
コンパイル使用メモリ | 199,384 KB |
最終ジャッジ日時 | 2025-02-13 17:43:08 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll n, k; cin >> n >> k; vector<ll> v(n), c(100010, 0); for(ll i = 0; i < n; i++) cin >> v[i]; for(ll i = 0; i < n; i++) c[v[i]]++; sort(c.rbegin(), c.rend()); ll s = 0; for(ll i = 0; i < n; i++) { if(s + c[i] >= k) { cout << i + 1 << "\n"; break; } s += c[i]; } }