結果

問題 No.45 回転寿司
ユーザー jcm_2jcm_2
提出日時 2019-08-14 23:22:10
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 519 bytes
コンパイル時間 42 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 41,456 KB
最終ジャッジ日時 2024-04-21 02:58:36
合計ジャッジ時間 3,449 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
39,168 KB
testcase_01 AC 63 ms
39,424 KB
testcase_02 WA -
testcase_03 AC 62 ms
39,424 KB
testcase_04 AC 63 ms
39,424 KB
testcase_05 AC 63 ms
39,424 KB
testcase_06 AC 69 ms
39,040 KB
testcase_07 AC 65 ms
39,424 KB
testcase_08 WA -
testcase_09 AC 64 ms
39,296 KB
testcase_10 AC 61 ms
39,168 KB
testcase_11 WA -
testcase_12 AC 64 ms
39,168 KB
testcase_13 AC 63 ms
39,424 KB
testcase_14 AC 62 ms
39,168 KB
testcase_15 AC 62 ms
39,424 KB
testcase_16 WA -
testcase_17 AC 60 ms
39,168 KB
testcase_18 AC 64 ms
39,296 KB
testcase_19 WA -
testcase_20 AC 62 ms
39,424 KB
testcase_21 AC 63 ms
39,424 KB
testcase_22 AC 62 ms
39,296 KB
testcase_23 WA -
testcase_24 AC 62 ms
39,424 KB
testcase_25 AC 63 ms
39,040 KB
testcase_26 AC 63 ms
39,296 KB
testcase_27 WA -
testcase_28 AC 63 ms
39,296 KB
testcase_29 AC 63 ms
39,040 KB
testcase_30 AC 63 ms
39,168 KB
testcase_31 AC 62 ms
39,168 KB
testcase_32 WA -
testcase_33 AC 63 ms
39,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
  const data = input.trim().split("\n")
  const N = parseInt(data[0])
  const values = data[1].split(" ").map(v => parseInt(v))
  let checked = Array.apply(null, Array(N)).map(() => -1)
  checked[0] = values[0]
  if (N === 1) {
    console.log(checked[0])
    return
  }
  checked[1] = values[1]
  for (let i = 1; i < N - 1; i++) {
    checked[i + 1] = Math.max(checked[i], checked[i - 1] + values[i + 1])
  }
  console.log(checked[N - 1])
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))
0