結果

問題 No.5 数字のブロック
ユーザー natu7925s
提出日時 2025-06-12 13:22:38
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 417 bytes
コンパイル時間 13,520 ms
コンパイル使用メモリ 379,264 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2025-06-12 13:26:57
合計ジャッジ時間 13,478 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        l: i32,
        n: usize,
        mut w: [i32; n],
    }
    w.sort();
    let mut sum = 0;
    let mut cnt = 0;
    for i in 0..n {
        sum += w[i];
        if sum >= l {
            cnt = i as i32;
            break;
        }
    }

    if sum < l {
        cnt = n as i32;
    } else if sum == l {
        cnt += 1;
    }
    
    println!("{}", cnt);
}
0