結果

問題 No.602 隠されていたゲーム2
ユーザー locol23locol23
提出日時 2021-12-01 10:58:08
言語 TypeScript
(5.4.3)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 8,113 ms
コンパイル使用メモリ 253,464 KB
実行使用メモリ 57,000 KB
最終ジャッジ日時 2023-09-17 15:05:41
合計ジャッジ時間 11,825 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,072 KB
testcase_01 AC 79 ms
41,924 KB
testcase_02 AC 79 ms
42,144 KB
testcase_03 AC 80 ms
42,108 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 79 ms
42,168 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 81 ms
42,184 KB
testcase_16 AC 95 ms
43,840 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 147 ms
56,664 KB
testcase_21 AC 147 ms
56,472 KB
testcase_22 WA -
testcase_23 AC 157 ms
56,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from 'fs'

const main = () => {
  const input = fs.readFileSync('/dev/stdin', 'utf8').split('\n')

  const [n] = input[0].split(' ').map((x: string): number => +x)
  const d = input[1].split(' ').map((x: string): number => +x)
  const [x, y] = input[2].split(' ').map((x: string) => +x)

  const targetDistance = Math.abs(x) + Math.abs(y)
  let incrementAcc = 0
  let decrementAcc = 0

  for (let i = 0, len = n; i < len; i++) {
    if (d[i] === 0) {
      return console.log(0)
    }

    if (d[i] === targetDistance) {
      return console.log(1)
    }

    if (incrementAcc === targetDistance) {
      return console.log(2)
    }

    if (decrementAcc === targetDistance) {
      return console.log(2)
    }

    incrementAcc += d[i]
    decrementAcc -= d[i]
  }

  return console.log(-1)
}

main()
0