結果

問題 No.5 数字のブロック
ユーザー packet0
提出日時 2015-12-24 01:36:54
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 549 bytes
コンパイル時間 11,405 ms
コンパイル使用メモリ 403,696 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-18 08:01:06
合計ジャッジ時間 12,756 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();

    let input: Vec<_> = stdin.lock().lines().map(|r| r.unwrap()).collect();

    let l: u32 = input[0].parse().unwrap();
    //let n: u32 = input[1].parse().unwrap();
    let mut w: Vec<u32> = input[2].split_whitespace().map(|s| s.parse().unwrap()).collect();
    w.sort();

    let mut sum: u32 = 0;
    let mut count: u32 = 0;
    for i in w {
        sum += i;
        if sum > l {
            break;
        }
        count += 1;
    }
    println!("{}", count);

}
0