結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2023-06-06 17:12:15 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,170 bytes |
コンパイル時間 | 16,535 ms |
コンパイル使用メモリ | 377,316 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 08:36:25 |
合計ジャッジ時間 | 17,430 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
macro_rules! scan_iter { ($buf:expr) => {{ use std::io::{stdin, BufRead}; use std::str::FromStr; $buf.clear(); stdin().lock().read_line(&mut $buf).unwrap(); $buf.trim() .split(" ") .map(|x| FromStr::from_str(x).unwrap()) }}; } macro_rules! scan_vec { ($buf:expr) => { scan_iter!($buf).collect::<Vec<_>>() }; } macro_rules! scan { ($buf:expr) => {{ use std::io::{stdin, BufRead}; use std::str::FromStr; $buf.clear(); stdin().lock().read_line(&mut $buf).unwrap(); FromStr::from_str($buf.trim()).unwrap() }}; } macro_rules! ignore { () => {{ use std::io::{stdin, BufRead}; stdin().lock().read_line(&mut String::new()).unwrap(); }}; } fn main() { let mut b = String::new(); let l: i32 = scan!(b); ignore!(); let w: Vec<i32> = { let mut w = scan_vec!(b); w.sort_unstable(); w }; let mut cap = l; let mut count = 0; for b in w { if cap < b { break; } cap -= b; count += 1; } println!("{count}"); }