結果
問題 | No.2334 Distinct Cards |
ユーザー |
|
提出日時 | 2023-06-02 21:23:43 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,614 bytes |
コンパイル時間 | 4,898 ms |
コンパイル使用メモリ | 129,168 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-28 16:11:54 |
合計ジャッジ時間 | 2,168 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>using namespace std;using i64 = long long;#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)#define all(x) x.begin(),x.end()#define STRINGIFY(n) #n#define TOSTRING(n) STRINGIFY(n)#define PREFIX "#" TOSTRING(__LINE__) "| "#define debug(x) \{ \std::cout << PREFIX << #x << " = " << x << std::endl; \}std::ostream& output_indent(std::ostream& os, int ind) {for(int i = 0; i < ind; i++) os << " ";return os;}template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p);template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);template<class S, class T> std::ostream& operator<<(std::ostream& os, const std::pair<S, T>& p) {return (os << "(" << p.first << ", " << p.second << ")");}template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {os << "[";for(int i = 0;i < v.size();i++) os << v[i] << ", ";return (os << "]");}template<class T>static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }template<class... Tail>static inline auto ndvec(size_t&& n, Tail&&... tail) {return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));}int main() {int N, K;cin >> N >> K;vector<i64> A(N);vector<i64> C(N);for(int i = 0; i < N; i++) {cin >> A[i];A[i]--;C[A[i]]++;}std::sort(C.rbegin(), C.rend());int cnt = 0;int j = 0;while(cnt < K) {cnt += C[j++];}cout << j << endl;}