結果

問題 No.5 数字のブロック
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-09-08 16:16:09
言語 Rust
(1.72.1)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 146,628 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:32:03
合計ジャッジ時間 2,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let l: i32 = getline().trim().parse().unwrap();
    let n: i32 = getline().trim().parse().unwrap();
    let line = getline();
    let blockwidths_string: Vec<_> = line.trim().split(' ').collect();

    let mut blockwidths = Vec::new();
    for i in 0..n {
        let ui = i as usize;
        blockwidths.push(blockwidths_string[ui].parse::<i32>().unwrap());
    }

    blockwidths.sort();

    let mut block_count = 0;
    let mut blockwidth_total = 0;

    for blockwidth in &blockwidths {
        if blockwidth + blockwidth_total < l {
            block_count += 1;
            blockwidth_total += blockwidth;
        }
    }

    println!("{}", block_count);
}
0