結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2022-11-17 01:30:35 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 15,801 ms |
コンパイル使用メモリ | 384,556 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-17 19:51:05 |
合計ジャッジ時間 | 17,032 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
use std::{ io::{self, BufRead}, process::exit, }; fn main() { let lines = io::stdin() .lock() .lines() .map(std::result::Result::unwrap) .collect::<Vec<_>>(); let length = lines[0].parse::<usize>().unwrap(); let mut widths = lines[2] .split(' ') .map(|w| w.parse::<usize>().unwrap()) .collect::<Vec<_>>(); widths.sort_unstable(); let mut i = 0; let mut sum = 0; while i < widths.len() { sum += widths[i]; if sum > length { println!("{}", i); exit(0); } i += 1; } println!("{}", i); }