結果
問題 | No.2334 Distinct Cards |
ユーザー |
|
提出日時 | 2023-06-02 22:23:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 55 ms / 2,000 ms |
コード長 | 439 bytes |
コンパイル時間 | 1,027 ms |
コンパイル使用メモリ | 80,888 KB |
最終ジャッジ日時 | 2025-02-13 18:54:28 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>int main() {int N, K;std::cin >> N >> K;std::vector<std::pair<int,int> > V(N + 1, {0, 0});for(int i = 0; i < N; i++) {int a;std::cin >> a;V[a].first++;V[a].second = a;}std::sort(V.rbegin(), V.rend());int ans = 0;int idx = 0;while(K>0&&idx<=N){K-=V[idx].first;if(V[idx].first > 0) ans++;idx++;}std::cout << ans << std::endl;return 0;}