結果

問題 No.156 キャンディー・ボックス
ユーザー ontama_12ontama_12
提出日時 2016-09-26 14:11:55
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 1,032 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 5,384 KB
実行使用メモリ 44,408 KB
最終ジャッジ日時 2023-08-03 01:44:45
合計ジャッジ時間 4,115 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
44,272 KB
testcase_01 AC 85 ms
42,520 KB
testcase_02 AC 87 ms
42,232 KB
testcase_03 AC 82 ms
42,228 KB
testcase_04 AC 83 ms
42,232 KB
testcase_05 AC 81 ms
42,388 KB
testcase_06 AC 79 ms
42,372 KB
testcase_07 AC 81 ms
44,316 KB
testcase_08 AC 79 ms
42,300 KB
testcase_09 AC 80 ms
42,472 KB
testcase_10 AC 80 ms
42,236 KB
testcase_11 AC 83 ms
42,332 KB
testcase_12 AC 81 ms
44,408 KB
testcase_13 AC 81 ms
42,240 KB
testcase_14 AC 81 ms
42,364 KB
testcase_15 AC 81 ms
42,244 KB
testcase_16 AC 80 ms
42,464 KB
testcase_17 AC 79 ms
42,272 KB
testcase_18 AC 80 ms
42,396 KB
testcase_19 AC 81 ms
42,240 KB
testcase_20 AC 82 ms
42,336 KB
testcase_21 AC 81 ms
42,396 KB
testcase_22 AC 82 ms
42,280 KB
testcase_23 AC 81 ms
42,520 KB
testcase_24 AC 80 ms
42,232 KB
testcase_25 AC 81 ms
42,316 KB
testcase_26 AC 80 ms
42,232 KB
testcase_27 AC 78 ms
42,276 KB
testcase_28 AC 79 ms
42,288 KB
testcase_29 AC 80 ms
42,292 KB
testcase_30 AC 82 ms
42,392 KB
testcase_31 AC 82 ms
42,356 KB
testcase_32 AC 80 ms
42,296 KB
testcase_33 AC 80 ms
42,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

    /////////////////////No.156 キャンディー・ボックス
    //入力文字読み取り
    process.stdin.resume();
    process.stdin.setEncoding('utf8');
    process.stdin.on('data', function (chunk) {

        //すべて受け取り改行で区切って格納
        var inputall = chunk.split("\n");

        //4つの数字を提示する回数
        var candy = inputall[0].split(" ");

        var candyboxall = Number(candy[0]);
        var manycandy = Number(candy[1]);

        var candybox = inputall[1].split(" ").map(Number);

        //ソート
        candybox.sort(function (a, b) {
            if (a < b) return -1;
            if (a > b) return 1;
            return 0;
        });

        var result = 0;
        var i=0
        while (true) {
            result += candybox[i]
            if (result == manycandy) {
                i++
                break;
            } else if (result > manycandy) {
                break;
            }
            i++
        }
        console.log(i);
    });
0