結果

問題 No.5 数字のブロック
ユーザー yu0912yu0912
提出日時 2020-07-23 14:04:58
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 207 ms / 5,000 ms
コード長 661 bytes
コンパイル時間 32 ms
コンパイル使用メモリ 5,212 KB
実行使用メモリ 46,624 KB
最終ジャッジ日時 2023-09-05 22:12:21
合計ジャッジ時間 5,055 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
42,244 KB
testcase_01 AC 79 ms
42,216 KB
testcase_02 AC 78 ms
42,276 KB
testcase_03 AC 207 ms
45,444 KB
testcase_04 AC 87 ms
43,444 KB
testcase_05 AC 162 ms
43,716 KB
testcase_06 AC 85 ms
43,508 KB
testcase_07 AC 84 ms
43,464 KB
testcase_08 AC 87 ms
43,452 KB
testcase_09 AC 81 ms
42,344 KB
testcase_10 AC 92 ms
43,848 KB
testcase_11 AC 84 ms
42,692 KB
testcase_12 AC 87 ms
43,588 KB
testcase_13 AC 91 ms
43,876 KB
testcase_14 AC 78 ms
44,208 KB
testcase_15 AC 79 ms
42,156 KB
testcase_16 AC 92 ms
43,780 KB
testcase_17 AC 93 ms
44,056 KB
testcase_18 AC 93 ms
43,824 KB
testcase_19 AC 96 ms
46,624 KB
testcase_20 AC 80 ms
42,160 KB
testcase_21 AC 79 ms
42,320 KB
testcase_22 AC 78 ms
42,280 KB
testcase_23 AC 80 ms
42,240 KB
testcase_24 AC 78 ms
42,344 KB
testcase_25 AC 77 ms
42,196 KB
testcase_26 AC 78 ms
44,176 KB
testcase_27 AC 77 ms
42,324 KB
testcase_28 AC 80 ms
42,184 KB
testcase_29 AC 87 ms
43,388 KB
testcase_30 AC 81 ms
42,520 KB
testcase_31 AC 78 ms
42,244 KB
testcase_32 AC 78 ms
42,180 KB
testcase_33 AC 79 ms
42,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function main(input = ``) {
  let lines = input.split('\n');

  let [boxSize] = lines[0].split(' ').map((val) => parseInt(val));
  let blockSizes = lines[2]
    .split(' ')
    .map((val) => parseInt(val))
    .sort((a, b) => a - b);

  let currentSize = 0;
  let numBoxes = 0;

  blockSizes.forEach((blockSize) => {
    if (currentSize + blockSize <= boxSize) {
      numBoxes += 1;
      currentSize += blockSize;
    }
  });

  return `${numBoxes}`;
}

const { readFileSync, existsSync } = require('fs');
const stdin = '/dev/stdin';

if (existsSync(stdin)) {
  const input = readFileSync(stdin, 'utf8');
  console.log(main(input));
}

module.exports = main;
0