結果
| 問題 | 
                            No.5 数字のブロック
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-08-20 16:20:28 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 857 bytes | 
| コンパイル時間 | 12,040 ms | 
| コンパイル使用メモリ | 379,200 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-13 12:47:11 | 
| 合計ジャッジ時間 | 13,360 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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 does not need to be mutable
  --> src/main.rs:13:9
   |
13 |     let mut L: i64 = lv[0].parse().unwrap(); // 箱の幅
   |         ----^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` 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 = 0;
    let mut sum: i64 = 0;
    for item in W.iter() {
        let x: i64 = item.to_string().parse().unwrap();
        sum += x;
        if sum > L {
            break;
        }
        count += 1;
    }
    println!("{}", count);
}