結果

問題 No.5 数字のブロック
ユーザー mondo
提出日時 2019-08-12 16:49:00
言語 JavaScript
(node v23.5.0)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 6,692 KB
実行使用メモリ 43,520 KB
最終ジャッジ日時 2024-10-13 01:20:01
合計ジャッジ時間 3,514 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

let main = (standardInput) => {
    var line = standardInput.split("\n");
    var largebox = line[0];
    var smallbox = line[2].split(" ");
    var int_largebox = Number(largebox); 
    var int_smallbox = smallbox.map(Number);
    // console.log(int_smallbox);
    int_smallbox.sort(
        function(a, b){
            return a - b;
        }
    );
    // console.log(int_smallbox);
    var max = 0;
    var count = 0;
    int_smallbox.forEach(function(element) {
    if ((max += element) <= int_largebox) {
        // console.log(element);
        count ++;
    }
});
console.log(count);
};

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));
0