結果
問題 | No.5 数字のブロック |
ユーザー | 🇳🇱🦭🇯🇵 |
提出日時 | 2024-09-04 10:53:27 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 824 bytes |
コンパイル時間 | 12,375 ms |
コンパイル使用メモリ | 391,460 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-04 10:53:41 |
合計ジャッジ時間 | 13,932 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
use std::io; use std::io::prelude::*; fn main() { let stdin = io::read_to_string(io::stdin()).unwrap(); let mut stdin = stdin.split_whitespace(); let stdout = io::stdout(); let mut stdout = io::BufWriter::new(stdout.lock()); let l: usize = stdin.next().unwrap().parse::<usize>().unwrap(); let n: usize = stdin.next().unwrap().parse::<usize>().unwrap(); let mut wn: Vec<usize> = vec![198471237812781; 100010]; for i in 0..n { wn[i] = stdin.next().unwrap().parse::<usize>().unwrap(); } wn.sort_unstable(); let sequence: Vec<_> = wn.into_iter().scan(0, |state, x| { *state += x; if *state > l { None } else { Some(*state) } }).collect(); writeln!(stdout, "{}", sequence.len()).unwrap_or(()); }