結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2020-08-20 16:29:35 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 835 bytes |
| コンパイル時間 | 13,777 ms |
| コンパイル使用メモリ | 384,924 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-13 12:59:30 |
| 合計ジャッジ時間 | 15,036 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 21 |
コンパイルメッセージ
warning: unused variable: `N`
--> src/main.rs:14:9
|
14 | let N: i64 = nv[0].parse().unwrap(); // ブロックの数
| ^ help: if this is intentional, prefix it with an underscore: `_N`
|
= note: `#[warn(unused_variables)]` on by default
warning: variable `L` should have a snake case name
--> src/main.rs:13:13
|
13 | let mut L: i64 = lv[0].parse().unwrap(); // 箱の幅
| ^ help: convert the identifier to snake case: `l`
|
= note: `#[warn(non_snake_case)]` on by default
warning: variable `N` should have a snake case name
--> src/main.rs:14:9
|
14 | let N: i64 = nv[0].parse().unwrap(); // ブロックの数
| ^ help: convert the identifier to snake case: `n`
warning: variable `W` should have a snake case name
--> src/main.rs:15:13
|
15 | let mut W: Vec<_> = w.trim().split(' ').collect(); // 各ブロックの幅
| ^ help: convert the identifier to snake case (notice the capitalization): `w`
ソースコード
fn getline() -> String{
let mut __ret=String::new();
std::io::stdin().read_line(&mut __ret).ok();
return __ret;
}
fn main() {
let l = getline();
let n = getline();
let w = getline();
let lv: Vec<_> = l.trim().split(' ').collect();
let nv: Vec<_> = n.trim().split(' ').collect();
let mut L: i64 = lv[0].parse().unwrap(); // 箱の幅
let N: i64 = nv[0].parse().unwrap(); // ブロックの数
let mut W: Vec<_> = w.trim().split(' ').collect(); // 各ブロックの幅
// 小さい順でブロックを箱に詰めていくのでソートする
W.sort();
let mut count: i64 = 0;
for item in W.iter() {
let x: i64 = item.to_string().parse().unwrap();
L = L - x;
if L < 0 {
break;
}
count += 1;
}
println!("{}", count);
}