結果

問題 No.2334 Distinct Cards
ユーザー EvbCFfp1XBEvbCFfp1XB
提出日時 2023-06-02 22:54:28
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 454 bytes
コンパイル時間 22,607 ms
コンパイル使用メモリ 401,924 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-28 21:13:02
合計ジャッジ時間 19,961 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;
fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let mut counts = vec![0; n + 1];
    (0..n).for_each(|i| counts[a[i]] += 1);
    counts.sort_by(|a, b| b.cmp(a));
    let mut position = 0;
    let mut sum = 0;
    for i in 0..n + 1 {
        sum += counts[position];
        if sum >= k {
            position = i + 1;
            break;
        }
    }

    println!("{}", position);
}
0