結果
問題 |
No.1046 Fruits Rush
|
ユーザー |
![]() |
提出日時 | 2022-12-15 00:07:52 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 492 bytes |
コンパイル時間 | 15,295 ms |
コンパイル使用メモリ | 379,976 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 16:34:30 |
合計ジャッジ時間 | 16,387 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 3 |
ソースコード
fn main() { let mut xx = String::new(); std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok(); let xx: Vec<&str> = xx.split_whitespace().collect(); let k: usize = xx[1].parse().unwrap(); let mut xx: Vec<i64> = xx[2..].iter().map(|&n| n.parse().unwrap()).collect(); xx.sort_unstable(); xx.reverse(); let i = k.min(xx.iter().position(|&x| x <= 0).unwrap_or(xx.len())); let answer = xx[..i].iter().sum::<i64>(); println!("{}", answer); }