結果

問題 No.5 数字のブロック
コンテスト
ユーザー かわなか
提出日時 2016-01-06 18:52:29
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 610 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,623 ms
コンパイル使用メモリ 199,748 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-12 20:30:03
合計ジャッジ時間 5,957 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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_right()).unwrap());
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)]` (part of `#[warn(unused)]`) on by default

ソースコード

diff #
raw source code

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