結果

問題 No.5 数字のブロック
ユーザー n3k2t1n3k2t1
提出日時 2019-07-07 17:27:49
言語 JavaScript
(node v21.7.1)
結果
RE  
実行時間 -
コード長 643 bytes
コンパイル時間 47 ms
コンパイル使用メモリ 6,812 KB
実行使用メモリ 444,044 KB
最終ジャッジ日時 2024-04-21 02:42:22
合計ジャッジ時間 9,005 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
39,936 KB
testcase_01 AC 83 ms
40,320 KB
testcase_02 AC 76 ms
40,192 KB
testcase_03 AC 1,679 ms
418,228 KB
testcase_04 AC 123 ms
51,072 KB
testcase_05 RE -
testcase_06 AC 1,186 ms
208,896 KB
testcase_07 AC 1,138 ms
299,824 KB
testcase_08 AC 813 ms
198,680 KB
testcase_09 AC 423 ms
105,940 KB
testcase_10 AC 1,096 ms
287,104 KB
testcase_11 AC 461 ms
112,600 KB
testcase_12 AC 1,645 ms
421,756 KB
testcase_13 AC 1,124 ms
286,976 KB
testcase_14 AC 150 ms
56,388 KB
testcase_15 AC 94 ms
46,808 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 1,595 ms
392,912 KB
testcase_19 RE -
testcase_20 AC 184 ms
42,324 KB
testcase_21 AC 83 ms
42,060 KB
testcase_22 AC 79 ms
40,320 KB
testcase_23 AC 78 ms
42,188 KB
testcase_24 AC 94 ms
48,588 KB
testcase_25 AC 319 ms
85,504 KB
testcase_26 AC 76 ms
39,936 KB
testcase_27 AC 80 ms
42,484 KB
testcase_28 AC 80 ms
42,188 KB
testcase_29 AC 113 ms
53,068 KB
testcase_30 AC 198 ms
70,912 KB
testcase_31 AC 81 ms
42,460 KB
testcase_32 AC 86 ms
42,196 KB
testcase_33 AC 102 ms
42,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//
let L, N, W;

//
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', data => {
  const arr = data.split('\n');
  L = Number(arr[0]);
  N = Number(arr[1]);
  W = arr[2].split(' ').map(x => Number(x));
});

process.stdin.on('end', () => {
  const dp = new Array(N + 1);
  for (let i = 0; i < dp.length; i++) {
    dp[i] = new Array(L + 1).fill(0);
  }
  for (let i = 0; i < N; i++) {
    for (let j = 0; j <= L; j++) {
      if (j < W[i]) {
        dp[i + 1][j] = dp[i][j];
      } else {
        dp[i + 1][j] = Math.max(dp[i][j], dp[i][j - W[i]] + 1);
      }
    }
  }
  console.log(Math.max(dp[N][L]));
});
0