結果

問題 No.5 数字のブロック
コンテスト
ユーザー YU Hirose
提出日時 2024-07-18 23:13:37
言語 JavaScript
(node v25.8.2)
コンパイル:
true
実行:
node _filename_ ONLINE_JUDGE
結果
AC  
実行時間 44 ms / 5,000 ms
+ 355µs
コード長 370 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 18 ms
コンパイル使用メモリ 5,888 KB
実行使用メモリ 57,184 KB
最終ジャッジ日時 2026-08-17 18:49:57
合計ジャッジ時間 5,308 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

function Main(input) {
    input = input.split("\n");
    const l = parseInt(input[0]);
    const w = input[2].split(" ").map(s=>parseInt(s));
    w.sort((x,y)=>x-y);
    let res = 0;
    let cnt = 0;
    for (let x of w) {
        res += x;
        if (res > l) break;
        cnt++;
    }
    console.log(cnt);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0