結果

問題 No.2334 Distinct Cards
ユーザー D4Cngo_cppD4Cngo_cpp
提出日時 2023-06-03 20:55:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 4,246 ms
コンパイル使用メモリ 252,288 KB
最終ジャッジ日時 2025-02-13 22:27:17
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace std;
using ll = long long;
#define reps(i, a, n) for(ll i = (a); i < (ll)(n); ++i)
#define rep(i,n) reps(i,0,n)
#define all(a) (a).begin(), (a).end()
//なんかstd::vector<bool>の挙動を修正できるやつ

/* alias */
using ull = unsigned long long;

using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
int main(){
    
    int n,k;
    cin >> n >>k;
    vi a(n,0);
    rep(i,n){
        int x;
        cin >> x;
        x--;
        a[x]++;
    }
    sort(all(a));
    reverse(all(a));
    int sum = 0, cnt=0;
    
    rep(i,n){
        sum+=a[i];
        if(sum >= k){
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << n << endl;
}
0