結果

問題 No.5 数字のブロック
ユーザー かわなか
提出日時 2016-01-06 18:52:29
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 12,596 ms
コンパイル使用メモリ 390,880 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 08:02:43
合計ジャッジ時間 13,850 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end`
  --> src/main.rs:27:32
   |
27 |         v.push(i32::from_str(i.trim_right()).unwrap());
   |                                ^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
help: replace the use of the deprecated method
   |
27 |         v.push(i32::from_str(i.trim_end()).unwrap());
   |                                ~~~~~~~~

warning: unused variable: `n`
 --> src/main.rs:6:9
  |
6 |     let n = lread()[0];
  |         ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

use std::io::stdin;
use std::str::FromStr;

fn main(){
    let mut l = lread()[0];
    let n = lread()[0];
    let mut w = lread();
    w.sort();
    let mut result = 0;
    for i in w {
        l -= i;
        if l < 0 {
            break;
        } else {
            result += 1;
        }
    }
    println!("{}",result);
        
}
fn lread() -> Vec<i32> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    let z: Vec<&str> = line.split(' ').collect();
    let mut v: Vec<i32> = vec![];
    for i in &z {
        v.push(i32::from_str(i.trim_right()).unwrap());
    }
    v
}
0