結果
問題 |
No.2334 Distinct Cards
|
ユーザー |
![]() |
提出日時 | 2023-06-02 22:58:54 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 897 bytes |
コンパイル時間 | 14,495 ms |
コンパイル使用メモリ | 400,576 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-28 21:27:40 |
合計ジャッジ時間 | 15,829 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 13 |
ソースコード
fn main() { let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let mut input_iter = input.split_whitespace(); let n: usize = input_iter.next().unwrap().parse().unwrap(); let k: usize = input_iter.next().unwrap().parse().unwrap(); let mut a = Vec::new(); let mut input = String::new(); std::io::stdin().read_line(&mut input).unwrap(); let input_iter = input.split_whitespace(); for num in input_iter { let num: usize = num.parse().unwrap(); a.push(num); } let mut counts = vec![0; n + 1]; for i in 0..n { 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); }