結果

問題 No.5 数字のブロック
ユーザー nomeaning
提出日時 2019-04-15 21:12:12
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 745 bytes
コンパイル時間 14,664 ms
コンパイル使用メモリ 390,216 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 14:21:09
合計ジャッジ時間 14,343 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
 --> src/main.rs:7:9
  |
7 |     let n: i32 = n.trim().parse().expect("Failed to parse N");
  |         ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

fn main() {
    let mut l = String::new();
    std::io::stdin().read_line(&mut l).expect("Failed to read L");
    let mut l: i32 = l.trim().parse().expect("Failed to parse L");
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).expect("Failed to read N");
    let n: i32 = n.trim().parse().expect("Failed to parse N");
    let mut w = String::new();
    std::io::stdin().read_line(&mut w).expect("Failed to read w");
    let mut w: Vec<i32> = w.trim().split_whitespace().map(|x| x.parse::<i32>().expect("Failed to parse w")).collect::<Vec<_>>();
    w.sort_unstable();
    let mut answer = 0;
    for ww in w {
        if l - ww >= 0 {
            l -= ww;
            answer+=1;
        }
    }
    println!("{}", answer);
}
0