結果

問題 No.602 隠されていたゲーム2
ユーザー locol23locol23
提出日時 2021-12-01 10:53:31
言語 TypeScript
(5.4.3)
結果
WA  
実行時間 -
コード長 604 bytes
コンパイル時間 8,453 ms
コンパイル使用メモリ 254,772 KB
実行使用メモリ 56,688 KB
最終ジャッジ日時 2023-09-17 14:57:25
合計ジャッジ時間 10,379 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
42,088 KB
testcase_01 AC 77 ms
42,088 KB
testcase_02 AC 78 ms
42,232 KB
testcase_03 AC 78 ms
42,084 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 78 ms
42,296 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 76 ms
42,260 KB
testcase_16 AC 86 ms
43,948 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 139 ms
56,688 KB
testcase_21 AC 143 ms
56,276 KB
testcase_22 WA -
testcase_23 AC 140 ms
55,140 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 acc = 0

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

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

main()
0