結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
penguinshunya
|
| 提出日時 | 2017-12-30 23:41:02 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 593 bytes |
| コンパイル時間 | 15,151 ms |
| コンパイル使用メモリ | 402,008 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-18 11:54:43 |
| 合計ジャッジ時間 | 16,337 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:3:9 | 3 | let n: u32 = read(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
fn main() {
let l: u32 = read();
let n: u32 = read();
let mut w: Vec<u32> = read_vec();
w.sort();
let mut count = 0;
let mut sum = 0;
for e in w {
sum += e;
if l < sum {
break;
}
count += 1;
}
println!("{}", count);
}
fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>().split_whitespace()
.map(|e| e.parse().ok().unwrap()).collect()
}
penguinshunya